Skip to content

Locally commit fleximod code in order to avoid false diff. #10

Locally commit fleximod code in order to avoid false diff.

Locally commit fleximod code in order to avoid false diff. #10

Workflow file for this run

#Github Action to ensure that
#the "fxtag" and "url" values
#in the ".gitmodules" file
#match what is actually
#stored in the committed
#git submodule entries.
#Please note that 'git-fleximod'
#is not actually needed for this
#repo, it is simply being used
#here to run the test described
#above.
#on: pull_request
on:
push:
branches:
- fleximod_test
pull_request:
jobs:
fleximod-test:
runs-on: ubuntu-latest
steps:
- name: checkout atmospheric_physics
uses: actions/checkout@v4
- name: checkout python v3.12
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: checkout git-fleximod
uses: actions/checkout@v4
with:
repository: ESMCI/git-fleximod
fetch-depth: 1
ref: main
path: .lib/git-fleximod #Must use relative path here.
# This action is needed to prevent fleximod
# from tripping over itself:
- name: Remove git info from fleximod checkout
run: rm -rf .lib/git-fleximod/.git
- name: create git-fleximod script
run: |
echo
echo "Creating git-fleximod python srcript..."
ls -a $GITHUB_WORKSPACE
ls -a ..
ls $GITHUB_WORKSPACE/.lib/git-fleximod #DEBUG-JN
#Create new directory:
mkdir $GITHUB_WORKSPACE/bin
#Write python script to expected location:
cat <<EOF > $GITHUB_WORKSPACE/bin/git-fleximod
#!/usr/bin/env python3
import sys
import os
sys.path.insert(0,os.path.abspath(os.path.join(os.path.dirname(__file__),"..",".lib","git-fleximod")))
print(os.path.abspath(os.path.join(os.path.dirname(__file__),"..",".lib","git-fleximod"))) #DEBUG-JN
from git_fleximod.git_fleximod import main
if __name__ == '__main__':
sys.exit(main())
EOF
#Make sure python script is executable:
chmod a+x $GITHUB_WORKSPACE/bin/git-fleximod
echo "...git-fleximod python script generated."
# Need to commit the new code locally
# in order to avoid a git diff failure.
- name: commit fleximod code
run: |
git add .lib
git add bin
git commit -m "Committing git-fleximod to avoid false diff"
- name: run git-fleximod
run: |
$GITHUB_WORKSPACE/bin/git-fleximod update -o
echo
echo "Update complete, checking status"
echo
$GITHUB_WORKSPACE/bin/git-fleximod test
- name: check cleanliness
run: |
echo
echo "Checking if git fleximod matches expected externals"
echo
git add . && git diff --exit-code && git diff --cached --exit-code