Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model Repro CI #2

Merged
merged 77 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
346e865
Added config/ and repro-ci.yml: release branch configurations
CodeGat Dec 19, 2023
0812279
README.md: Fixed markdown violations
CodeGat Jan 14, 2024
7c45198
Added test/: Pulled in bitwise repro scripts from cosima/access-om2
CodeGat Jan 14, 2024
0f9e999
Added pr-1-ci.yml for PR-specific CI logic
CodeGat Jan 15, 2024
73bd123
Added schedule-*.yml for Schedule-specific CI logic
CodeGat Jan 15, 2024
ebdff14
repro-ci.yml: Modified into a reusable workflow, added stub steps
CodeGat Jan 15, 2024
9db9f1c
pr-1-ci.yml: Added rough draft of steps for this workflow
CodeGat Jan 16, 2024
05505c9
Added bump-1-ci.yml, will be responsible for tagging a new ground tru…
CodeGat Jan 16, 2024
5ee7b21
repro-ci.yml: Focus of this workflow is now to generate and upload ch…
CodeGat Jan 16, 2024
344762c
schedule-2-start.yml: Added a stub check-repro job and stub outcomes …
CodeGat Jan 16, 2024
bfad339
released-configs/json: Added invalid JSON comment on tag formation
CodeGat Jan 16, 2024
98a5422
bump-1-ci.yml: Added code to add tag to main based on VERSION
CodeGat Jan 16, 2024
2f21183
Added check-repro.yml, a reusable workflow responsible for comparing …
CodeGat Jan 16, 2024
ec8a4e2
pr-1-ci.yml: References new check-repro.yml workflow
CodeGat Jan 17, 2024
bcc8ea4
schedule-2-start.yml: References new check-repro.yml workflow
CodeGat Jan 17, 2024
8d28870
repro-ci.yml: Formatted rsync command correctly
CodeGat Jan 17, 2024
445d343
Updated files with TODOs
CodeGat Jan 17, 2024
43a1289
Updated all uses of config-branch to config-tag
CodeGat Jan 17, 2024
273182b
check-repro.yml: Added logic for checking checksums
CodeGat Jan 17, 2024
5831f78
Removed some TODOs
CodeGat Jan 17, 2024
98b8f40
pr-1-ci.yml: Added different messages depending on release or dev con…
CodeGat Jan 17, 2024
fc4b7a7
Converted reusable check-repo.yml into an action to account for diffe…
CodeGat Jan 18, 2024
001ecf1
Moved repro-ci.yml and check-repro action to access-nri/reproducibili…
CodeGat Jan 18, 2024
6b57523
Added new workflow to bump VERSION file, renamed bump-1-ci, updated p…
CodeGat Jan 23, 2024
65c07e1
Added prevent-merge.yml: This forces a failure of checks when VERSION…
CodeGat Jan 23, 2024
d01df93
schedule-*: Added issue creation as a drastic measure, and made the m…
CodeGat Jan 23, 2024
945582b
schedule-1-ci: Inheritied the appropriate permissions
CodeGat Jan 24, 2024
edcb680
schedule-2-start: Updated call to checksum-check action with checksum…
CodeGat Jan 24, 2024
5eea597
pr-1-ci: Added checksum-name field to checksum-check action
CodeGat Jan 24, 2024
fcfbc0e
bump-version-file.yml: Formatting
CodeGat Jan 24, 2024
9abaf14
pr-1-ci.yml: Added TODOs
CodeGat Jan 24, 2024
3ae70bc
Added CONTRIBUTING.md, README-DEV.md and updated README.md to referen…
CodeGat Jan 25, 2024
63b6622
schedule-1-ci.yml: Added workflow_dispatch trigger
CodeGat Jan 25, 2024
ce7b813
Updated CI to use repro-ci's new experiment-location output
CodeGat Jan 25, 2024
26b987d
bump-version-file.yml: Updated regex for <type>-<experiment>-<tag> fo…
CodeGat Jan 25, 2024
f84ce7b
Add pytests for checking model reproducibility.
jo-basevi Jan 24, 2024
ccd47ed
Update pytests: Add pytest option --checksum-path for path of checksu…
jo-basevi Jan 29, 2024
f6dab99
Add pytest marker for checksum and update test readme
jo-basevi Jan 29, 2024
4c7455a
Fixes to updated reproducibility call, TODOs, PR comments
CodeGat Jan 29, 2024
254e5bb
Added validate-json.yml for config validation, updated README-DEV.md …
CodeGat Jan 29, 2024
70ebaf3
README.md: Fixed formatting errors
CodeGat Jan 29, 2024
b5383ee
Added comments to all workflows
CodeGat Jan 29, 2024
7f5a394
pr-1-ci.yml: Added proper on.paths-ignore, updated checksum-check out…
CodeGat Jan 29, 2024
c09e0d9
Appended 'pr-*-' to pr-adjacent workflows
CodeGat Jan 31, 2024
9b98418
TODOs and fixes from partial review
CodeGat Jan 31, 2024
b12a91d
Refactored workflow to commit and push at the same point, removing th…
CodeGat Jan 31, 2024
4690031
Update tests: Add checksum schema versioning support
jo-basevi Jan 31, 2024
2eb95b9
Add a test output access-om2.out file
jo-basevi Jan 31, 2024
e456645
Consolidated the commit and push logic into the bump comment workflow
CodeGat Jan 31, 2024
d6b9558
Update .github/workflows/pr-1-ci.yml
CodeGat Feb 2, 2024
ab8af5b
Updated pr-1-ci.yml to reference a section on config tags in the READ…
CodeGat Feb 2, 2024
5fa57c4
README-DEV.md: Formatting
CodeGat Feb 2, 2024
2584d99
Update .github/workflows/pr-2-confirm.yml
CodeGat Feb 2, 2024
5c76c5f
pr-2-confirm.yml: Added comment regarding regex
CodeGat Feb 2, 2024
1705db2
Update .github/workflows/schedule-2-start.yml
CodeGat Feb 2, 2024
1686a9f
Removed all references to the VERSION file, instead referencing metad…
CodeGat Feb 4, 2024
3b76634
Apply suggestions from code review
jo-basevi Feb 7, 2024
52bd32a
Updated pr-* with fixes from final test
CodeGat Feb 12, 2024
450aff3
pr-1-ci.yml: Changed double to single quotes for comments to allow co…
CodeGat Feb 12, 2024
d4ba6f2
pr-2-confirm.yml: changed mv to cp
CodeGat Feb 12, 2024
8a1a096
Update test/test_bit_reproducibility.py
CodeGat Feb 14, 2024
54f4bfa
exp_test_helper.py: removed __future__ import
CodeGat Feb 15, 2024
78cdcc3
accessom2.py: Added examples of checksum regex
CodeGat Feb 15, 2024
ef9b19e
test_bit_reproducibility.py: Renamed output checksum file from `CHECK…
CodeGat Feb 15, 2024
a26f780
removed schema dir, updated models/accessom2 and test/test/test_acces…
CodeGat Feb 18, 2024
961df03
Added requirements.txt for tests
CodeGat Feb 19, 2024
399d733
Updated filenames for test resources and now use get_schema_from_url()
CodeGat Feb 19, 2024
dcd42ab
Updated requirements.txt to have jsonschema
CodeGat Feb 19, 2024
7d6943b
Added new skippable 'test' marker to conftest for test tests
CodeGat Feb 19, 2024
b153021
Removed skip marker from test_extract_checksums
CodeGat Feb 19, 2024
27877fb
Modified path to checksum resource in test test
CodeGat Feb 19, 2024
a958592
test_bit_reproducibility: Added a check for checksum_path existence, …
CodeGat Feb 20, 2024
933b161
Modified checksum style to be dict[str, any] rather than list[dict[st…
CodeGat Feb 21, 2024
a9b65f3
Changed `yaml` functions to their appropriate `json` equivalents, ren…
CodeGat Feb 21, 2024
bae7e47
output_checksums are now a defaultdict[str, list[any]]
CodeGat Feb 21, 2024
00d6cbc
JSON dumps are now pretty-printed
CodeGat Feb 21, 2024
f3810d4
Added updated test/resources
CodeGat Feb 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 153 additions & 0 deletions .github/workflows/pr-1-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: PR Checks
on:
pull_request:
branches:
- 'release-*'
- 'dev-*'
paths-ignore:
# These are ignored because they don't have anything to do with the model itself
- .github/**
- tools/**
- doc/**
- .*
- metadata.yaml
- README.md
jobs:
commit-check:
name: Commit Check
# We run this job to check if the current commit was done during a workflow run.
# Such as when 'github-actions' bumps the metadata.yaml file or updates the checksums
# in the `testing` directory.
# This is so we don't recursively commit and check infinitely during this workflow.
runs-on: ubuntu-latest
outputs:
authorship: ${{ steps.head-commit.outputs.authorship }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: HEAD Commit Authorship
id: head-commit
run: echo "authorship=$(git log -1 --pretty=format:'%an')" >> $GITHUB_OUTPUT

repro-ci:
# run the given config on the deployment GitHub Environment (`environment-name`) and
# upload the checksums and test details
needs:
- commit-check
if: needs.commit-check.outputs.authorship != 'github-actions'
uses: access-nri/reproducibility/.github/workflows/checks.yml@main
aidanheerdegen marked this conversation as resolved.
Show resolved Hide resolved
with:
model-name: access-om2
environment-name: Gadi
config-tag: ${{ github.head_ref }}
test-markers: checksum
secrets: inherit
permissions:
contents: write

check-checksum:
# Parse the test report and return pass/fail result
name: Check and Update Checksum
needs:
- repro-ci
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
env:
TESTING_LOCAL_LOCATION: /opt/testing
outputs:
# URL for the parsed test results
check-run-url: ${{ steps.results.outputs.check-url }}
# Overall result of the checksum repro CI - `pass` (if reproducible), `fail` otherwise
result: ${{ steps.results.outputs.result }}
# Version of the checksum compared against the newly generated one
compared-checksum-version: ${{ steps.results.outputs.compared-checksum-version }}
steps:
- name: Download Newly Created Checksum
uses: actions/download-artifact@v3
with:
name: ${{ needs.repro-ci.outputs.artifact-name }}
path: ${{ env.TESTING_LOCAL_LOCATION }}

- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
fetch-tags: true

- name: Parse Test Report
id: tests
uses: EnricoMi/publish-unit-test-result-action/composite@e780361cd1fc1b1a170624547b3ffda64787d365 #v2.12.0
with:
files: ${{ env.TESTING_LOCAL_LOCATION }}/checksum/test_report.xml
aidanheerdegen marked this conversation as resolved.
Show resolved Hide resolved
comment_mode: off
check_run: true
compare_to_earlier_commit: false
report_individual_runs: true
report_suite_logs: any

- name: Checksum Tests Results
id: results
run: |
echo "check-url=${{ fromJson(steps.tests.outputs.json).check_url }}" >> $GITHUB_OUTPUT
echo "compared-checksum-version=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
if [ "${{ fromJson(steps.tests.outputs.json).stats.tests_fail }}" > 0 ]; then
echo "result=fail" >> $GITHUB_OUTPUT
else
echo "result=pass" >> $GITHUB_OUTPUT
fi

result:
name: Repro Result Notifier
# Notify the PR of the result of the Repro check
needs:
- repro-ci
- check-checksum
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Successful Release Comment
if: needs.check-checksum.outputs.result == 'pass' && startsWith(github.base_ref, 'release-')
env:
BODY: |
:white_check_mark: The Bitwise Reproducibility check succeeded when comparing against `${{ needs.check-checksum.outputs.compared-checksum-version }}` for this `Release` config. :white_check_mark:
For further information, the experiment can be found on Gadi at ${{ needs.repro-ci.outputs.experiment-location }}, and the test results at ${{ needs.check-checksum.outputs.check-run-url }}.
Consider bumping the minor version of `access-om2-configs` - to bump the version, comment `!bump minor`. The meaning of these version bumps is explained in the README.md, under `Config Tags`.
run: gh pr comment --body '${{ env.BODY }}'

- name: Successful Dev Comment
if: needs.check-checksum.outputs.result == 'pass' && startsWith(github.base_ref, 'dev-')
env:
BODY: |
:white_check_mark: The Bitwise Reproducibility check succeeded when comparing against `${{ needs.check-checksum.outputs.compared-checksum-version }}` for this `Dev` config. :white_check_mark:
For further information, the experiment can be found on Gadi at ${{ needs.repro-ci.outputs.experiment-location }}, and the test results at ${{ needs.check-checksum.outputs.check-run-url }}.
run: gh pr comment --body '${{ env.BODY }}'

- name: Failed Release Comment
if: needs.check-checksum.outputs.result == 'fail' && startsWith(github.base_ref, 'release-')
env:
BODY: |
:x: The Bitwise Reproducibility check failed when comparing against `${{ needs.check-checksum.outputs.compared-checksum-version }}` for this `Release` config. :x:
For further information, the experiment can be found on Gadi at ${{ needs.repro-ci.outputs.experiment-location }}, and the test results at ${{ needs.check-checksum.outputs.check-run-url }}.
You must bump the major version of `access-om2-configs` before this PR is merged to account for this - to bump the version, comment `!bump major`. The meaning of these version bumps is explained in the README.md, under `Config Tags`.
run: gh pr comment --body '${{ env.BODY }}'

- name: Failed Dev Comment
if: needs.check-checksum.outputs.result == 'fail' && startsWith(github.base_ref, 'dev-')
env:
BODY: |
:warning: The Bitwise Reproducibility check failed when comparing against `${{ needs.check-checksum.outputs.compared-checksum-version }}` for this `Dev` config. :warning:
For further information, the experiment can be found on Gadi at ${{ needs.repro-ci.outputs.experiment-location }}, and the test results at ${{ needs.check-checksum.outputs.check-run-url }}.
run: gh pr comment --body '${{ env.BODY }}'
160 changes: 160 additions & 0 deletions .github/workflows/pr-2-confirm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# This workflow is used to do a major/minor version bump to the `metadata.yaml` file,
# through a comment on the PR. It also commits and pushes the checksum file,
# as this is the last stage before merging.
# This is not done automatically because users may want to modify their config
# based on the result of the reproducibility check.
name: Confirm
on:
issue_comment:
types:
- created
- edited
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
jobs:
bump-version:
name: Bump metadata.yaml
# Bump the `metadata.yaml` file if the comment is made on a PR and starts with '!bump'
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '!bump')
runs-on: ubuntu-latest
outputs:
# metadata.yaml version before being bumped
before: ${{ steps.bump.outputs.before }}
# metadata.yaml version after being bumped
after: ${{ steps.bump.outputs.after }}
# The type of bump - 'major' or 'minor'
type: ${{ steps.type.outputs.bump }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_COMMIT_CHECK_TOKEN }}

- name: Checkout Associated PR ${{ github.event.issue.number }}
# Since the trigger for this workflow was on.issue_comment, we need
# to do a bit more wrangling to checkout the pull request
id: pr
run: gh pr checkout ${{ github.event.issue.number }}

- name: Get Type of Bump
id: type
run: |
if [[ "${{ contains(github.event.comment.body, 'minor') }}" == "true" ]]; then
echo "bump=minor" >> $GITHUB_OUTPUT
elif [[ ${{ contains(github.event.comment.body, 'major') }} == "true" ]]; then
echo "bump=major" >> $GITHUB_OUTPUT
else
echo "::error::Comment was not of the form: '!bump [major|minor]'"
exit 1
fi

- name: Bump
# Regarding the regex in the script: `([0-9]+)\.([0-9]+)` is broken down into:
# `([0-9]+)`: Major version (eg. `12`)
# `\.`: Version separator (eg. `.`)
# `([0-9]+)`: Minor version (eg. `1`)
# which would give `12.1`
id: bump
run: |
version=$(yq '.version' metadata.yaml)
regex="([0-9]+)\.([0-9]+)"
if [[ $version =~ $regex ]]; then
major_version="${BASH_REMATCH[1]}"
minor_version="${BASH_REMATCH[2]}"
else
echo "::error::Invalid version format in metadata.yaml file!"
exit 1
fi

if [[ "${{ steps.type.outputs.bump }}" == "minor" ]]; then
minor_version=$((minor_version + 1))
elif [[ "${{ steps.type.outputs.bump }}" == "major" ]]; then
major_version=$((major_version + 1))
minor_version=0
fi
new_version="${major_version}.${minor_version}"
echo "before=$version" >> $GITHUB_OUTPUT
echo "after=$new_version" >> $GITHUB_OUTPUT

commit:
name: Commit metadata.yaml and Checksum
needs:
- bump-version
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
GH_TOKEN: ${{ secrets.GH_COMMIT_CHECK_TOKEN }}
ARTIFACT_LOCAL_LOCATION: /opt/artifact
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GH_COMMIT_CHECK_TOKEN }}

- name: Checkout Associated PR ${{ github.event.issue.number }}
# Since the trigger for this workflow was on.issue_comment, we need
# to do a bit more wrangling to checkout the pull request and get the branch name
id: pr
run: |
gh pr checkout ${{ github.event.issue.number }}
echo "branch=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT

- name: Download Newly Created Checksum
# Given the PR branch, we need to find the latest associated workflow run
# on this branch we can then download the associated artifact
run: |
associated_run=$(gh run list \
--json='databaseId,headBranch,updatedAt,status' \
--jq='[.[] | select(.headBranch == "${{ steps.pr.outputs.branch }}" and .status == "completed")] | sort_by(.updatedAt) | last | .databaseId')
gh run download $associated_run -D ${{ env.ARTIFACT_LOCAL_LOCATION }}

- name: Update metadata.yaml and Checksum files
run: |
yq -i '.version = "${{ needs.bump-version.outputs.after }}"' metadata.yaml
cp --recursive --verbose ${{ env.ARTIFACT_LOCAL_LOCATION }}/*/* testing

- name: Commit and Push Updates
run: |
git config user.name github-actions
git config user.email [email protected]

if [[ "${{ needs.bump-version.outputs.type }}" == "minor" ]]; then
git commit -am "Bumped version to ${{ needs.bump-version.outputs.after }} as part of ${{ env.RUN_URL }}"
elif [[ "${{ needs.bump-version.outputs.type }}" == "major" ]]; then
git commit -am "Updated checksums and bumped version to ${{ needs.bump-version.outputs.after }} as part of ${{ env.RUN_URL }}"
fi
git push

- name: Comment Success
env:
BODY: |
:white_check_mark: Version bumped from `${{ needs.bump-version.outputs.before }}` to `${{ needs.bump-version.outputs.after }}` :white_check_mark:
run: gh pr comment --body '${{ env.BODY }}'

failure-notifier:
name: Failure Notifier
if: failure()
needs:
- commit
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Checkout Associated PR ${{ github.event.issue.number }}
run: gh pr checkout ${{ github.event.issue.number }}

- name: Comment Failure
env:
BODY: |
:x: Failed to bump VERSION or commit changes, see ${{ env.RUN_URL }} :x:
run: gh pr comment --body '${{ env.BODY }}'
41 changes: 41 additions & 0 deletions .github/workflows/pr-3-bump-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow is used to convert the `.version` in the `metadata.yaml` file into a valid `git tag` on push to `main`.
# We use the `.version` field in that file to denote the version of the config once a PR is merged.
name: Bump Tag
on:
push:
branches:
- 'release-*'
paths:
- 'metadata.yaml'
jobs:
tag-update:
name: Check and Update Tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true

- name: Existing Tag Check
# Check if the tag already exists, if it does, we don't want to move it.
id: tag
run: |
VERSION_TAG=${{ github.ref_name }}-$(yq '.version' metadata.yaml)
VERSION_TAG_ON_GIT=$(git tag -l $VERSION_TAG)
if [ -n "$VERSION_TAG_ON_GIT" ]; then
echo "::warning::Tag $VERSION_TAG already exists. Skipping."
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "version=$VERSION_TAG" >> $GITHUB_OUTPUT
fi

- name: Update Tag
if: steps.tag.outputs.exists == 'false'
run: |
git config user.name github-actions
git config user.email [email protected]
git tag ${{ steps.tag.outputs.version }}
git push --tags
36 changes: 36 additions & 0 deletions .github/workflows/schedule-1-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Scheduled Checks
on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *' # once a month
jobs:
setup:
name: Setup Tasks
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.get-released-config.outputs.tags }}
steps:
- uses: actions/checkout@v4
with:
ref: main

- name: Get all released configs
id: get-released-config
run: echo "tags=$(jq --compact-output --raw-output '.tags' config/released-configs.json)" >> $GITHUB_OUTPUT

repro-ci:
# We use this reusable workflow with a matrix strategy rather than calling repro-ci.yml, as
# we may want to do config-branch-specific tasks after the matrixed repro-ci.yml has completed.
needs:
- setup
strategy:
fail-fast: false
matrix:
config-tag: ${{ fromJson(needs.setup.outputs.tags) }}
uses: ./.github/workflows/schedule-2-start.yml
with:
config-tag: ${{ matrix.config-tag }}
secrets: inherit
permissions:
contents: write
issues: write
Loading
Loading