Skip to content

Commit

Permalink
Merge pull request NCAR#79 from climbfuji/update_gsl_develop_from_dev…
Browse files Browse the repository at this point in the history
…elop

Update gsl/develop from develop 2021/05/21
  • Loading branch information
DomHeinzeller committed May 21, 2021
2 parents dde703b + bf96c8a commit eae7d9c
Show file tree
Hide file tree
Showing 180 changed files with 30,573 additions and 14,227 deletions.
150 changes: 150 additions & 0 deletions .github/workflows/aux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: Helpers
on:
workflow_run:
workflows: ["Pull Request Tests"]
types:
- requested
env:
app: Accept:application/vnd.github.v3+json
base_url: $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs
AUTH: ${{ secrets.GITHUB_TOKEN }}
aws_instance_id: ${{ secrets.AWS_INSTANCE_ID }}
no_instances: 6


jobs:
pre:
name: Preprocess
runs-on: ubuntu-20.04

steps:
- name: Share helper id
run: echo -n ${{ github.run_id }} >~/id_file

- uses: actions/cache@v2
with:
path: ~/id_file
key: helperid-${{ github.event.workflow_run.id }}

- name: Delete run-ci label
run: |
head_sha=${{ github.event.workflow_run.head_sha }}
url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY
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
runs-on: ubuntu-20.04

steps:
- name: Check up-to-dateness and post comment
run: |
head_sha=${{ github.event.workflow_run.head_sha }}
git clone -q ${{ github.event.workflow_run.head_repository.html_url }} .
git checkout -q $head_sha
git submodule -q update --init --recursive
cd ${{ github.workspace }}/tests/ci
url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY
pr_number=$(curl -sS -H $app $url/pulls \
| jq -r '.[] | select(.head.sha == "'"$head_sha"'") | .number')
echo "pr_number is $pr_number"
pr_uid=${{ github.event.workflow_run.head_repository.owner.login }}
echo "pr_uid is $pr_uid"
comment="$(./repo_check.sh $pr_uid 2>/dev/null)"
echo "comment is $comment"
if [[ -n $comment ]]; then
curl -sS -X POST -H $app -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
$url/issues/$pr_number/comments -d '{"body": "'"${comment}"'"}'
echo -n "failure" >~/repocheck_file
else
echo -n "success" >~/repocheck_file
fi
- uses: actions/cache@v2
with:
path: ~/repocheck_file
key: repocheck-${{ github.event.workflow_run.id }}


startrunner:
name: Start runners
needs: repocheck
runs-on: ubuntu-20.04
outputs:
started: ${{ steps.ec2.outputs.started }}

steps:
- uses: actions/checkout@v2

- name: Check all builds are complete and successful
id: current
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)
if [ $b_r == 'success' ]; then
echo "::set-output name=check::pass"
elif [ $b_r == 'failure' ]; then
echo "::set-output name=check::fail"
fi
- name: Check all previous runs finish using ec2
id: previous
if: steps.current.outputs.check == 'pass'
run: |
cd ${{ github.workspace }}/tests/ci
eval url=$base_url
echo -n $url | ./check_status.py ec2 ${{ github.run_id }}
- uses: aws-actions/configure-aws-credentials@v1
if: steps.current.outputs.check == 'pass'
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Start ec2 instances
id: ec2
if: steps.current.outputs.check == 'pass'
run: |
no_stopped=0
while [ $no_stopped -lt $no_instances ]; do
sleep 20
no_stopped=$(aws ec2 describe-instances --instance-ids $aws_instance_id \
| jq -r '.Reservations[].Instances[].State.Name' | grep stopped | wc -l)
echo "no_stopped: $no_stopped"
done
aws ec2 start-instances --instance-ids $aws_instance_id
echo "::set-output name=started::yes"
stoprunner:
name: Stop runners
needs: startrunner
runs-on: ubuntu-20.04
if: needs.startrunner.outputs.started == 'yes'

steps:
- uses: actions/checkout@v2

- name: Check all tests are complete
run: |
cd ${{ github.workspace }}/tests/ci
eval url=$base_url/${{ github.event.workflow_run.id }}
echo $url | ./check_status.py test
- uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Stop ec2 instances
run: aws ec2 stop-instances --instance-ids $aws_instance_id
147 changes: 112 additions & 35 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,92 @@
name: Pull request tests

name: Pull Request Tests
on:
push:
branches: ['develop']
pull_request:
branches: ['develop']
types: ['labeled']
env:
app: Accept:application/vnd.github.v3+json


jobs:
repocheck:
name: Check if repos are up to date
runs-on: ubuntu-20.04

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

steps:
- uses: actions/checkout@v2

- name: Wait for caching source
run: sleep 30

- uses: actions/cache@v2
with:
path: ~/id_file
key: helperid-${{ github.run_id }}

- name: Wait until repocheck in aux is complete
run: |
helper_id=$(cat ~/id_file)
cd ${{ github.workspace }}/tests/ci
jobs_url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs/$helper_id/jobs
conclusion=$(echo $jobs_url | ./check_status.py completion "Repo check")
if [[ $conclusion == "failure" ]]; then
exit 1
fi
- uses: actions/cache@v2
with:
path: ~/repocheck_file
key: repocheck-${{ github.run_id }}

- name: Set repocheck currency flag
id: check
run: |
repocheck_result=$(cat ~/repocheck_file)
if [[ $repocheck_result == success ]]; then
echo "::set-output name=current::yes"
elif [[ $repocheck_result == failure ]]; then
echo "::set-output name=current::no"
fi
setup:
name: Set up
name: Configure cases to run
needs: [repocheck]
runs-on: ubuntu-20.04
if: needs.repocheck.outputs.current == 'yes' && github.event.label.name == 'run-ci'

outputs:
tn: ${{ steps.parse.outputs.tn }}
bld: ${{ steps.parse.outputs.bld }}
test: ${{ steps.parse.outputs.test }}
img: ${{ steps.parse.outputs.img }}

steps:
- name: Checkout codes
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Parse cases
- name: Collect cases to run
id: parse
run: |
cd ${GITHUB_WORKSPACE}/tests/ci
parsed_output=( $(./parse.sh) )
name_=${parsed_output[0]}
bld_=${parsed_output[1]}
test_=${parsed_output[2]}
img_=${parsed_output[3]}
echo "::set-output name=tn::$name_"
cd ${{ github.workspace }}/tests/ci
IFS='|'; parsed_output=( $(./setup.py) )
bld_=${parsed_output[0]}
test_=${parsed_output[1]}
img_=ci-test-weather
echo "::set-output name=bld::$bld_"
echo "::set-output name=test::$test_"
echo "::set-output name=img::$img_"
echo "test name : $name_"
echo "build set : $bld_"
echo "test set : $test_"
echo "image name: $img_"
echo "repocheck: ${{needs.repocheck.outputs.current}}"
build:
name: Build (${{ matrix.bld_set }})
name: Build ${{ matrix.bld_set }}
needs: setup
runs-on: ubuntu-20.04

Expand All @@ -51,8 +95,7 @@ jobs:
matrix: ${{ fromJson(needs.setup.outputs.bld) }}

steps:
- name: Checkout codes
uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
submodules: recursive

Expand All @@ -61,7 +104,7 @@ jobs:
printf '{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json >/dev/null
sudo systemctl restart docker
sleep 10
cd tests/ci && ./ci.sh -n ${{ needs.setup.outputs.tn }} -b ${{ matrix.bld_set }}
cd tests/ci && ./ci.sh -n ${{ matrix.name }} -b ${{ matrix.case }}
- name: Free up disk space
run: |
Expand All @@ -71,41 +114,75 @@ jobs:
- name: Prepare artifacts
run: |
cd tests/ci
sudo docker save ${{ needs.setup.outputs.img }} | gzip >${{ needs.setup.outputs.img }}.tar.gz
sudo docker save ${{ needs.setup.outputs.img }} \
| gzip >${{ needs.setup.outputs.img }}.tar.gz
tar cvjf artifact.tar.bz2 ${{ needs.setup.outputs.img }}.tar.gz ci.sh ci.test
- name: Upload artifacts
uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.bld_set }}.artifact.tar.bz2
path: tests/ci/artifact.tar.bz2


wait:
name: Wait for ec2 instances to start
needs: build
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/id_file
key: helperid-${{ github.run_id }}

- name: Check if ec2 instances started
run: |
cd ${{ github.workspace }}/tests/ci
helper_id=$(cat ~/id_file)
url=$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/runs/$helper_id/jobs
ec2_started=$(echo -n $url | ./check_status.py completion "Start runners")
if [ $ec2_started != 'success' ]; then
echo "ec2 instances did not start"
exit 1
fi
utest:
name: Unit test (${{ needs.setup.outputs.tn }}, ${{ matrix.test_set }})
needs: [setup,build]
name: Test ${{ matrix.test_set }}
needs: [setup,build,wait]
runs-on: self-hosted
#runs-on: ubuntu-20.04

strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.test) }}

steps:
- name: Download artifacts
uses: actions/download-artifact@v2
- name: Clean up in case of left-over files
run: |
rm -f artifact.tar.bz2 ${{ needs.setup.outputs.img }}.tar.gz
docker ps -a --filter "name=my-container" | grep my-container >/dev/null 2>&1 \
&& docker rm my-container >/dev/null 2>&1 && d=$? || d=$?
docker image ls | grep ${{ needs.setup.outputs.img }} >/dev/null 2>&1 \
&& docker rmi ${{ needs.setup.outputs.img }} >/dev/null 2>&1 && d=$? || d=$?
- uses: actions/download-artifact@v2
with:
name: ${{ matrix.artifact }}.artifact.tar.bz2

- name: Prepare artifacts
run: |
tar xvjf artifact.tar.bz2 && rm -f artifact.tar.bz2
docker load --input ${{ needs.setup.outputs.img }}.tar.gz && rm -f ${{ needs.setup.outputs.img }}.tar.gz
docker load --input ${{ needs.setup.outputs.img }}.tar.gz \
&& rm -f ${{ needs.setup.outputs.img }}.tar.gz
- name: Run utest
run: ./ci.sh -n ${{ needs.setup.outputs.tn }} -r ${{ matrix.test_set }}
run: ./ci.sh -n ${{ matrix.name }} -r ${{ matrix.case }}

- name: Upload memory usage file
- uses: actions/upload-artifact@v2
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: memory_stat_${{ matrix.test_set }}
path: memory_stat
Expand All @@ -114,7 +191,7 @@ jobs:
if: ${{ always() }}
run: |
rm -f ci.sh ci.test
docker stop my-container && docker rm my-container && docker rmi ${{ needs.setup.outputs.img }}:latest
docker stop my-container && docker rm my-container \
&& docker rmi ${{ needs.setup.outputs.img }}:latest
docker volume rm DataVolume
#docker rmi minsukjinoaa/fv3-input-data:input-data-20210115
rm -f memory_stat
Loading

0 comments on commit eae7d9c

Please sign in to comment.