Skip to content

Commit

Permalink
Change CI triggering method ufs-community#558
Browse files Browse the repository at this point in the history
* CI runs when run-ci label is created
* Old method of specifying run-ci in commit message is obsolete
* Push event no longer triggers the CI
* Minor fixes in aux.yml
  • Loading branch information
MinsukJi-NOAA committed May 12, 2021
1 parent 2f1c8e1 commit 15cd9d4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 45 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/aux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ jobs:
path: ~/id_file
key: helperid-${{ github.event.workflow_run.id }}

- name: Delete run-ci label
run: |
head_sha=${{ github.event.workflow_run.head_sha }}
echo "head_sha is $head_sha"
url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY
echo "url is $url"
pr_number=$(curl -sS -H $app $url/pulls \
| jq -r '.[] | select(.head.sha == "'"$head_sha"'") | .number')
echo "pr_number is $pr_number"
curl -sS -X DELETE -H $app -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
$url/issues/$pr_number/labels/run-ci
repocheck:
name: Repo check
Expand Down Expand Up @@ -86,7 +98,7 @@ jobs:
run: |
cd ${{ github.workspace }}/tests/ci
eval url=$base_url/${{ github.event.workflow_run.id }}/jobs
b_r=$(echo -n $url | ./check_status.py build $(./setup.py no_builds))
b_r=$(echo -n $url | ./check_status.py build)
if [ $b_r == 'success' ]; then
echo "::set-output name=check::pass"
elif [ $b_r == 'failure' ]; then
Expand Down
39 changes: 4 additions & 35 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Pull Request Tests
on:
push:
branches: ['develop']
pull_request:
branches: ['develop']
branches: ['feature/ci-label']
types: ['labeled']
env:
app: Accept:application/vnd.github.v3+json

Expand Down Expand Up @@ -53,41 +52,11 @@ jobs:
fi
runcheck:
name: Check if run-ci is requested
runs-on: ubuntu-20.04

outputs:
cirun: ${{ steps.check.outputs.cirun }}

steps:
- name: Check
id: check
run: |
if [[ ${{github.event_name}} == pull_request ]]; then
sha=${{github.event.pull_request.head.sha}}
url=$(echo ${{github.event.pull_request.head.repo.git_commits_url}} \
| sed "s:{/sha}:/$sha:")
elif [[ ${{github.event_name}} == push ]]; then
sha=${{github.event.after}}
url=$(echo ${{github.event.repository.git_commits_url}} | sed "s:{/sha}:/$sha:")
fi
message="$(curl -sS -H "$app" $url | jq '.message')"
echo $message | grep run-ci >/dev/null 2>&1 && d=$? || d=$?
if [[ $d -eq 0 ]]; then
echo "::set-output name=cirun::yes"
elif [[ $d -eq 1 ]]; then
echo "::set-output name=cirun::no"
fi
printf "Commit message is %s\n" "$message"
setup:
name: Configure cases to run
needs: [repocheck,runcheck]
needs: [repocheck]
runs-on: ubuntu-20.04
if: needs.repocheck.outputs.current == 'yes' && needs.runcheck.outputs.cirun == 'yes'
if: needs.repocheck.outputs.current == 'yes' && github.event.label.name == 'run-ci'

outputs:
bld: ${{ steps.parse.outputs.bld }}
Expand Down
7 changes: 3 additions & 4 deletions tests/ci/check_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from datetime import datetime, timedelta


def check_build(request, no_builds):
def check_build(request):
"""Check if all build jobs are completed successfully.
API endpoint: api.github.com/repos/{owner}/{repo}/actions/runs/{run_id}/jobs
"""
Expand All @@ -20,7 +20,7 @@ def check_build(request, no_builds):
ids = [x["id"] for x in data if re.search("Build", x["name"])]
if len(ids) == 1 and next(re.search("matrix", x["name"]) for x in data if x["id"] in ids):
break
if len(ids) != no_builds:
if len(ids) == 0:
continue
all_completed = all(
[x["status"] == "completed" for x in data if x["id"] in ids])
Expand Down Expand Up @@ -109,8 +109,7 @@ def main():
pass

if sys.argv[1] == "build":
print("success") if check_build(
request, int(sys.argv[2])) else print("failure")
print("success") if check_build(request) else print("failure")
elif sys.argv[1] == "completion":
print("success") if check_completion(
request, sys.argv[2]) else print("failure")
Expand Down
2 changes: 1 addition & 1 deletion tests/default_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ elif [[ $MACHINE_ID = hera.* ]]; then
elif [[ $MACHINE_ID = linux.* ]]; then

if [[ $CI_TEST = true ]]; then
TASKS_dflt=42 ; TPN_dflt=48 ; INPES_dflt=3 ; JNPES_dflt=2
TASKS_dflt=12 ; TPN_dflt=48 ; INPES_dflt=1 ; JNPES_dflt=1
else
TASKS_dflt=150 ; TPN_dflt=40 ; INPES_dflt=3 ; JNPES_dflt=8
fi
Expand Down
8 changes: 4 additions & 4 deletions tests/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ atparse < ${PATHRT}/parm/${NEMS_CONFIGURE:-nems.configure} > nems.configure
if [[ $SCHEDULER = 'none' ]]; then

ulimit -s unlimited
if [[ $CI_TEST = 'true' ]]; then
eval mpiexec -n ${TASKS} ${MPI_PROC_BIND} ./fv3.exe >out 2> >(tee err >&3)
else
#if [[ $CI_TEST = 'true' ]]; then
# eval mpiexec -n ${TASKS} ${MPI_PROC_BIND} ./fv3.exe >out 2> >(tee err >&3)
#else
mpiexec -n ${TASKS} ./fv3.exe >out 2> >(tee err >&3)
fi
#fi

else

Expand Down

0 comments on commit 15cd9d4

Please sign in to comment.