Skip to content

Commit

Permalink
Merge pull request #24 from ACCESS-NRI/23-add-infra
Browse files Browse the repository at this point in the history
Addition of generic workflows from `ACCESS-NRI/access-om2-configs`
  • Loading branch information
CodeGat committed Jun 19, 2024
2 parents c025d99 + 59da225 commit 6885b16
Show file tree
Hide file tree
Showing 11 changed files with 901 additions and 45 deletions.
40 changes: 40 additions & 0 deletions .github/actions/parse-ci-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# parse-ci-config

This action parses the CI testing configuration file. The caller of the action needs to checkout the branch where the config file is defined before running this action.

## Inputs

| Name | Type | Description | Required | Example |
| ---- | ---- | ----------- | -------- | ------- |
| check | `string` | The type of check/test to run | true | `scheduled` |
| branch-or-tag | `string` | The name of git branch or tag | true | `release-1deg_jra55_ryf-2.0` |
| config-filepath | `string` | Path to configuration file | true | `config/ci.json` |

## Outputs

| Name | Type | Description | Example |
| ---- | ---- | ----------- | -------- |
| markers | `string` | Markers used for the pytest checks, in the python format | `checksum` |
| model-config-tests-version | `string` | The version of the model-config-tests | `0.0.1` |
| python-version | `string` | The python version used to create test virtual environment | `3.11.0` |

## Example usage

```yaml
# ---------
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main

- name: Read scheduled test config
id: scheduled-config
uses: access-nri/model-config-tests/.github/actions/parse-ci-config@main
with:
check: scheduled
branch-or-tag: "release-1deg_jra55_ryf-2.0"
config-filepath: "config/ci.json"
```
53 changes: 53 additions & 0 deletions .github/actions/parse-ci-config/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Parse CI Config File
description: Action to parse model-config-tests configurations for CI tests
inputs:
check:
required: true
description: Type of check/test to run (e.g. "reproducibility", "qa" or "scheduled")
branch-or-tag:
required: true
description: Name of Git branch or tag to run CI testing on
config-filepath:
required: true
description: Path to CI configuration file
outputs:
model-config-tests-version:
value: ${{ steps.read-config.outputs.model-config-tests-version }}
description: A version of the model-config-tests package
python-version:
value: ${{ steps.read-config.outputs.python-version }}
description: The python version used to create test virtual environment
markers:
value: ${{ steps.read-config.outputs.markers }}
description: A python expression of markers to pass to model-config-tests pytests
runs:
using: "composite"
steps:
- name: Read Configuration File
shell: bash
id: read-config
run: |
# Fall back to default config values if not defined for a given branch or tag
output=$(jq --arg branch "${{ inputs.branch-or-tag }}" --arg check "${{ inputs.check }}" '
{
"model-config-tests-version": (
.[$check][$branch]["model-config-tests-version"] //
.[$check].default["model-config-tests-version"] //
.default["model-config-tests-version"]
),
"python-version": (
.[$check][$branch]["python-version"] //
.[$check].default["python-version"] //
.default["python-version"]
),
"markers": (
.[$check][$branch].markers //
.[$check].default.markers //
.default.markers
),
}
' "${{ inputs.config-filepath }}")
echo "markers=$(echo "$output" | jq -r '.["markers"]')" >> $GITHUB_OUTPUT
echo "python-version=$(echo "$output" | jq -r '.["python-version"]')" >> $GITHUB_OUTPUT
echo "model-config-tests-version=$(echo "$output" | jq -r '.["model-config-tests-version"]')" >> $GITHUB_OUTPUT
6 changes: 6 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ on:
pull_request:
branches:
- 'main'
paths-ignore:
- .github/**
- .*
- '**.md'
- COPYRIGHT.txt
- LICENSE

jobs:
pre-commit:
Expand Down
Loading

0 comments on commit 6885b16

Please sign in to comment.