Skip to content

Commit 67792b1

Browse files
add github action
1 parent 961052c commit 67792b1

File tree

9 files changed

+306
-1
lines changed

9 files changed

+306
-1
lines changed

.github/workflows/test_cylc.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: test
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
schedule:
10+
- cron: '17 22 * * 6' # Every Saturday at 22:17
11+
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os: ['ubuntu-latest', 'macos-latest']
18+
micromamba_installed: [true, false]
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Mamba
25+
if: ${{ matrix.micromamba_installed }} == true
26+
uses: mamba-org/setup-micromamba@v1
27+
28+
- name: Setup Cylc
29+
uses: ./
30+
with:
31+
cylc_rose: true
32+
33+
- name: Version
34+
run: |
35+
cylc version
36+
37+
- name: Validate
38+
run: |
39+
# this should pass
40+
cylc validate ./example;
41+
# this should fail
42+
! cylc validate ./example -s ANSWER=6;
43+
44+
- name: Lint
45+
run: |
46+
# this should fail
47+
! cylc lint ./example > out;
48+
grep 'S004' out;
49+
grep 'found 1 issue' out;
50+
51+
- name: Rose Macro
52+
run: |
53+
# this should fail
54+
! rose macro -V -C ./example 2> err;
55+
grep 'issues: 1' err
56+
grep 'Not an integer' err
57+
58+
- name: Rose Metadata Check
59+
run: |
60+
rose metadata-check -C ./example/meta

.mailmap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# FORMAT: <proper-name> <proper-email> <commit-name> <commit-email>
2+
# Omit commit-name or commit-email if same as proper
3+
4+
Oliver Sanders <oliver.sanders@metoffice.gov.uk> Oliver sanders

CONTRIBUTING.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Cylc: How to Contribute
2+
3+
Thanks for you interest in the Cylc project!
4+
5+
Contributions are welcome, please open an issue to discuss changes before
6+
raising a pull request.
7+
8+
You can also get in touch via:
9+
10+
* The developers chat: [![chat](https://img.shields.io/matrix/cylc-general:matrix.org)](https://matrix.to/#/#cylc-general:matrix.org)
11+
* The forum: [![forum](https://img.shields.io/discourse/https/cylc.discourse.group/posts.svg)](https://cylc.discourse.group/)
12+
13+
14+
## New Contributors
15+
16+
Please read the [CLA](#contributor-licence-agreement-and-certificate-of-origin).
17+
18+
Please add your name to the
19+
[Code Contributors](#code-contributors) section of this file as part of your
20+
first Pull Request (for each Cylc repository you contribute to).
21+
22+
23+
## Code Contributors
24+
25+
The following people have contributed to this code under the terms of
26+
the Contributor Licence Agreement and Certificate of Origin detailed
27+
below:
28+
29+
<!-- start-shortlog -->
30+
- Oliver Sanders
31+
<!-- end-shortlog -->
32+
33+
(All contributors are identifiable with email addresses in the git version
34+
control logs or otherwise.)
35+
36+
37+
## Contributor Licence Agreement and Certificate of Origin
38+
39+
By making a contribution to this project, I certify that:
40+
41+
(a) The contribution was created in whole or in part by me and I have
42+
the right to submit it, either on my behalf or on behalf of my
43+
employer, under the terms and conditions as described by this file;
44+
or
45+
46+
(b) The contribution is based upon previous work that, to the best of
47+
my knowledge, is covered under an appropriate licence and I have
48+
the right or permission from the copyright owner under that licence
49+
to submit that work with modifications, whether created in whole or
50+
in part by me, under the terms and conditions as described by
51+
this file; or
52+
53+
(c) The contribution was provided directly to me by some other person
54+
who certified (a) or (b) and I have not modified it.
55+
56+
(d) I understand and agree that this project and the contribution
57+
are public and that a record of the contribution (including my
58+
name and email address) is retained for the full term of
59+
the copyright and may be redistributed consistent with this project
60+
or the licence(s) involved.
61+
62+
(e) I, or my employer, grant to NIWA and all recipients of
63+
this software a perpetual, worldwide, non-exclusive, no-charge,
64+
royalty-free, irrevocable copyright licence to reproduce, modify,
65+
prepare derivative works of, publicly display, publicly perform,
66+
sub-licence, and distribute this contribution and such modifications
67+
and derivative works consistent with this project or the licence(s)
68+
involved or other appropriate open source licence(s) specified by
69+
the project and approved by the
70+
[Open Source Initiative (OSI)](http://www.opensource.org/).
71+
72+
(f) If I become aware of anything that would make any of the above
73+
inaccurate, in any way, I will let NIWA know as soon as
74+
I become aware.
75+
76+
(The Cylc Contributor Licence Agreement and Certificate of Origin is
77+
inspired that of [Rose](https://github.com/metomi/rose), which in turn was
78+
inspired by the Certificate of Origin used by Enyo and the Linux Kernel.)

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2024, The Cylc Workflow Engine
3+
Copyright (c) NIWA & British Crown (Met Office) & Contributors.
44

55
Redistribution and use in source and binary forms, with or without
66
modification, are permitted provided that the following conditions are met:

README.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Setup Cylc Action
2+
3+
A GitHub action to install Cylc (and optionally Rose).
4+
5+
This action uses micromamba to install Cylc (and optionally Rose) into an
6+
environment called `cylc`. It puts the `cylc`, `isodatetime` (and optionally
7+
`rose`) commands in `$PATH` so they can be called by later steps in your
8+
workflow.
9+
10+
This action runs on the Linux and Mac OS runners (but not Windows).
11+
12+
13+
## Example Workflow
14+
15+
```yaml
16+
jobs:
17+
test:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Cylc
25+
uses: cylc/setup-cylc@v1
26+
with:
27+
cylc_rose: true
28+
29+
- name: Run Cylc Tests
30+
run: |
31+
cylc validate ./my-workflow
32+
cylc lint ./my-workflow
33+
34+
- name: Run Rose Tests
35+
run: |
36+
rose macro -V -C ./my-workflow
37+
rose metadata-check -C ./my-workflow/meta
38+
rose metadata-check -C ./my-workflow/app/my-app/meta
39+
```
40+
41+
42+
## Options
43+
44+
**``cylc_version``** [default 8]
45+
46+
The version of Cylc to install e.g:
47+
48+
```
49+
# install the latest version of Cylc 8
50+
cylc_version: 8
51+
52+
# install the latest version of Cylc 8.1
53+
cylc_version: 8.1
54+
55+
# install Cylc 8.1.1
56+
cylc_version: 8.1.1
57+
```
58+
59+
60+
**``cylc_rose``** [default false]
61+
62+
Install Rose along with Cylc Rose support.

action.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Setup Cylc
2+
description: Install Cylc.
3+
4+
inputs:
5+
cylc_version:
6+
description: 'The Cylc version to install (or an abbreviation e.g. 8 to pick up the latest version).'
7+
default: '8'
8+
cylc_rose:
9+
description: 'Install cylc-rose?'
10+
default: false
11+
12+
runs:
13+
using: composite
14+
steps:
15+
# check if micromamba is already installed
16+
- name: Check Mamba
17+
id: check_mamba
18+
continue-on-error: true
19+
shell: bash
20+
run: micromamba --version
21+
22+
# install micromamba if necessary
23+
- name: Install Mamba
24+
if: steps.check_mamba.outcome == 'failure'
25+
uses: mamba-org/setup-micromamba@v1
26+
with:
27+
init-shell: bash
28+
post-cleanup: 'all'
29+
30+
# install cylc (and cylc-rose if requested) into a mamba environment
31+
- name: Install Cylc
32+
shell: bash
33+
run: |
34+
# write env file
35+
cat > cylc_env.yml <<__ENV__
36+
name: cylc
37+
channels:
38+
- conda-forge
39+
dependencies:
40+
- cylc-flow-base=${{ inputs.cylc_version }}
41+
__ENV__
42+
43+
# install cylc-rose?
44+
if ${{ inputs.cylc_rose }}; then
45+
echo ' - cylc-rose' >> cylc_env.yml
46+
fi
47+
48+
# create environment
49+
micromamba env create -y --file=cylc_env.yml
50+
rm cylc_env.yml
51+
52+
# create required wrapper scripts
53+
- name: Install Wrapper
54+
shell: bash -el {0}
55+
run: |
56+
# create a temp dir for wrapper scripts
57+
cd $(mktemp -d)
58+
59+
# determine which wrappers to create
60+
micromamba activate cylc
61+
wrappers=(cylc isodatetime)
62+
if ${{ inputs.cylc_rose }}; then
63+
wrappers+=(rose)
64+
fi
65+
66+
# create a wrapper for each command in the temp dir
67+
for wrapper in "${wrappers[@]}"; do
68+
EXE="$(command -v "$wrapper")"
69+
cat > "$wrapper" <<__WRAPPER__
70+
#!/usr/bin/env bash
71+
exec "${EXE}" "\$@"
72+
__WRAPPER__
73+
74+
chmod +x "$wrapper"
75+
done
76+
77+
# add the temp dir to $PATH for future steps
78+
echo "$PWD" >> $GITHUB_PATH
79+
80+
# check the install worked
81+
- name: Test
82+
shell: bash
83+
run: |
84+
cylc version

example/flow.cylc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!jinja2
2+
3+
{% set ANSWER = ANSWER | default(42) %}
4+
{{ assert(ANSWER == 42, 'The constants are changing') }}
5+
6+
[scheduling]
7+
[[graph]]
8+
R1 = """
9+
foo
10+
"""
11+
12+
[runtime]
13+
[[foo]] # indentation is off here

example/meta/rose-meta.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[template variables=QUESTION]
2+
type=integer

example/rose-suite.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[template variables]
2+
QUESTION='What do you get if you multiply 6 by 7?'

0 commit comments

Comments
 (0)