| 1 |
name: functional tests |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_dispatch: |
| 5 |
pull_request: |
| 6 |
paths-ignore: |
| 7 |
- '.github/workflows/*.ya?ml' |
| 8 |
- '!.github/workflows/test_functional.yml' |
| 9 |
- 'cylc/flow/etc/syntax/**' |
| 10 |
- 'etc/syntax/**' |
| 11 |
- 'tests/conftest.py' |
| 12 |
- 'tests/unit/**' |
| 13 |
- 'tests/integration/**' |
| 14 |
- '**.md' |
| 15 |
- '**/README*/**' |
| 16 |
push: |
| 17 |
branches: |
| 18 |
- master |
| 19 |
- '8.*.x' |
| 20 |
paths-ignore: |
| 21 |
- '.github/workflows/*.ya?ml' |
| 22 |
- '!.github/workflows/test_functional.yml' |
| 23 |
- 'cylc/flow/etc/syntax/**' |
| 24 |
- 'etc/syntax/**' |
| 25 |
- 'tests/conftest.py' |
| 26 |
- 'tests/unit/**' |
| 27 |
- 'tests/integration/**' |
| 28 |
- '**.md' |
| 29 |
- '**/README*/**' |
| 30 |
|
| 31 |
concurrency: |
| 32 |
group: ${{ github.workflow }}-${{ github.ref }} |
| 33 |
cancel-in-progress: true |
| 34 |
|
| 35 |
defaults: |
| 36 |
run: |
| 37 |
shell: bash -c "exec $CONDA_PREFIX/bin/bash -elo pipefail {0}" |
| 38 |
|
| 39 |
env: |
| 40 |
FORCE_COLOR: 2 |
| 41 |
PIP_PROGRESS_BAR: off |
| 42 |
|
| 43 |
jobs: |
| 44 |
test: |
| 45 |
runs-on: ${{ matrix.os }} |
| 46 |
name: ${{ matrix.name || matrix.chunk }} |
| 47 |
timeout-minutes: 45 |
| 48 |
strategy: |
| 49 |
fail-fast: false |
| 50 |
matrix: |
| 51 |
os: ['ubuntu-22.04'] |
| 52 |
python-version: ['3.12'] # oldest version we support |
| 53 |
test-base: ['tests/f'] |
| 54 |
chunk: ['1/4', '2/4', '3/4', '4/4'] |
| 55 |
platform: ['_local_background* _local_at*'] |
| 56 |
# NOTE: includes must define ALL of the matrix values |
| 57 |
include: |
| 58 |
# latest python |
| 59 |
- name: 'py-3-latest' |
| 60 |
os: 'ubuntu-latest' |
| 61 |
python-version: '3' |
| 62 |
test-base: 'tests/f' |
| 63 |
chunk: '1/4' |
| 64 |
platform: '_local_background*' |
| 65 |
# tests/k |
| 66 |
- name: 'flaky' |
| 67 |
os: 'ubuntu-latest' |
| 68 |
python-version: '3.12' |
| 69 |
test-base: 'tests/k' |
| 70 |
chunk: '1/1' |
| 71 |
platform: '_local_background* _local_at*' |
| 72 |
# remote platforms |
| 73 |
- name: '_remote_background_indep_poll' |
| 74 |
os: 'ubuntu-latest' |
| 75 |
python-version: '3.12' |
| 76 |
test-base: 'tests/f tests/k' |
| 77 |
chunk: '1/1' |
| 78 |
platform: '_remote_background_indep_poll _remote_at_indep_poll' |
| 79 |
- name: '_remote_background_indep_tcp' |
| 80 |
os: 'ubuntu-latest' |
| 81 |
test-base: 'tests/f tests/k' |
| 82 |
python-version: '3.12' |
| 83 |
chunk: '1/1' |
| 84 |
platform: '_remote_background_indep_tcp _remote_at_indep_tcp' |
| 85 |
# macos |
| 86 |
- name: 'macos 1/5' |
| 87 |
os: 'macos-latest' |
| 88 |
python-version: '3.12' # oldest version we support |
| 89 |
test-base: 'tests/f' |
| 90 |
chunk: '1/5' |
| 91 |
platform: '_local_background*' |
| 92 |
- name: 'macos 2/5' |
| 93 |
os: 'macos-latest' |
| 94 |
python-version: '3' # newest available |
| 95 |
test-base: 'tests/f' |
| 96 |
chunk: '2/5' |
| 97 |
platform: '_local_background*' |
| 98 |
|
| 99 |
env: |
| 100 |
# Use non-UTC time zone |
| 101 |
TZ: XXX-05:30 |
| 102 |
# these vars are used by etc/bin/run-functional-tests |
| 103 |
CYLC_TEST_PLATFORMS: ${{ matrix.platform }} |
| 104 |
CYLC_COVERAGE: 1 |
| 105 |
REMOTE_PLATFORM: ${{ contains(matrix.platform, '_remote') }} |
| 106 |
|
| 107 |
steps: |
| 108 |
- name: Checkout |
| 109 |
uses: actions/checkout@v5 |
| 110 |
|
| 111 |
- name: Configure Python |
| 112 |
uses: mamba-org/setup-micromamba@v2 |
| 113 |
with: |
| 114 |
cache-environment: true |
| 115 |
post-cleanup: 'all' |
| 116 |
environment-name: cylc-functional-test |
| 117 |
create-args: >- |
| 118 |
python=${{ matrix.python-version }} |
| 119 |
pip |
| 120 |
bash |
| 121 |
coreutils |
| 122 |
grep |
| 123 |
sed |
| 124 |
sqlite |
| 125 |
subversion |
| 126 |
tree |
| 127 |
|
| 128 |
- name: Create global config |
| 129 |
run: | |
| 130 |
CONF_PATH="$HOME/.cylc/flow/8" |
| 131 |
mkdir -p "$CONF_PATH" |
| 132 |
touch "$CONF_PATH/global.cylc" |
| 133 |
ln -s "$CONF_PATH/global.cylc" "$CONF_PATH/global-tests.cylc" |
| 134 |
echo "GLOBAL_CFG_PATH=${CONF_PATH}/global.cylc" >> "$GITHUB_ENV" |
| 135 |
|
| 136 |
- name: Patch DNS |
| 137 |
uses: cylc/release-actions/patch-dns@v1 |
| 138 |
|
| 139 |
- name: Add localhost entries to global config |
| 140 |
if: startsWith(runner.os, 'macos') |
| 141 |
run: | |
| 142 |
cat >> "$GLOBAL_CFG_PATH" <<__HERE__ |
| 143 |
[platforms] |
| 144 |
[[localhost, $(hostname -f), $(hostname -s)]] |
| 145 |
hosts = localhost |
| 146 |
install target = localhost |
| 147 |
ssh command = ssh -oBatchMode=yes -oConnectTimeout=8 -oStrictHostKeyChecking=no |
| 148 |
__HERE__ |
| 149 |
cat "$GLOBAL_CFG_PATH" |
| 150 |
|
| 151 |
- name: Add .github/bin/ to PATH |
| 152 |
# Sets up mocked mail command & any other custom executables |
| 153 |
# Adding to $GITHUB_PATH does not work when using setup-micromamba and/or login shell |
| 154 |
run: | |
| 155 |
echo "export PATH=\"${{ github.workspace }}/.github/bin:$PATH\"" >> ~/.bash_profile |
| 156 |
|
| 157 |
- name: Install |
| 158 |
run: | |
| 159 |
pip install -e ."[all]" |
| 160 |
mkdir "$HOME/cylc-run" |
| 161 |
|
| 162 |
- name: Configure Atrun |
| 163 |
if: contains(matrix.platform, '_local_at') |
| 164 |
run: | |
| 165 |
sudo apt-get update |
| 166 |
sudo apt-get install -y at |
| 167 |
cat >> "$GLOBAL_CFG_PATH" << __HERE__ |
| 168 |
[platforms] |
| 169 |
[[_local_at_indep_tcp]] |
| 170 |
hosts = localhost |
| 171 |
install target = localhost |
| 172 |
job runner = at |
| 173 |
__HERE__ |
| 174 |
|
| 175 |
- name: Swarm Configure |
| 176 |
run: | |
| 177 |
etc/bin/swarm --yes --debug configure |
| 178 |
|
| 179 |
- name: Swarm Build |
| 180 |
if: env.REMOTE_PLATFORM == 'true' |
| 181 |
run: | |
| 182 |
# `swarm configure` seems to get ignored so override the user config |
| 183 |
cp etc/conf/ssh_config $HOME/.ssh/config |
| 184 |
# build and run the swarm |
| 185 |
etc/bin/swarm --yes --debug build |
| 186 |
etc/bin/swarm --yes --debug run |
| 187 |
# test that it's up and running before proceeding |
| 188 |
sleep 1 |
| 189 |
ssh -vv _remote_background_indep_poll hostname |
| 190 |
|
| 191 |
- name: Configure git # Needed by the odd test |
| 192 |
uses: cylc/release-actions/configure-git@v1 |
| 193 |
|
| 194 |
# Useful debug info: |
| 195 |
- name: Pip list |
| 196 |
run: pip list |
| 197 |
- name: Inspect versions |
| 198 |
run: | |
| 199 |
python --version |
| 200 |
echo |
| 201 |
rsync --version |
| 202 |
|
| 203 |
- name: Filter Tests |
| 204 |
env: |
| 205 |
# NOTE: we only want the CHUNK set in this step else we will |
| 206 |
# re-chunk tests later when they run |
| 207 |
CHUNK: ${{ matrix.chunk }} |
| 208 |
run: | |
| 209 |
etc/bin/run-functional-tests \ |
| 210 |
--dry \ |
| 211 |
${{ matrix.test-base }} \ |
| 212 |
> test-file |
| 213 |
if [[ $REMOTE_PLATFORM == 'true' ]]; then |
| 214 |
# skip tests that don't configure platform requirements |
| 215 |
grep -l --color=never REQUIRE_PLATFORM $(cat test-file) > test-file |
| 216 |
fi |
| 217 |
echo "----- Filtered Tests -----" |
| 218 |
sort test-file |
| 219 |
|
| 220 |
- name: Test |
| 221 |
id: test |
| 222 |
timeout-minutes: 35 |
| 223 |
continue-on-error: true |
| 224 |
run: | |
| 225 |
echo "finished=false" >> $GITHUB_OUTPUT |
| 226 |
if [[ '${{ matrix.test-base }}' == 'tests/k' ]]; then |
| 227 |
NPROC=4 |
| 228 |
else |
| 229 |
NPROC=8 |
| 230 |
fi |
| 231 |
# NOTE: test base is purposefully un-quoted |
| 232 |
etc/bin/run-functional-tests \ |
| 233 |
-j "${NPROC}" \ |
| 234 |
--state=save \ |
| 235 |
$(cat test-file) \ |
| 236 |
|| (echo "finished=true" >> $GITHUB_OUTPUT && false) |
| 237 |
|
| 238 |
- name: Time Out |
| 239 |
if: steps.test.outcome == 'failure' && steps.test.outputs.finished != 'true' |
| 240 |
run: | |
| 241 |
echo '::error:: tests timed-out' |
| 242 |
# help to identify the tests that were running at the time |
| 243 |
cylc scan --state=all --format=rich --color-blind |
| 244 |
# fail the workflow |
| 245 |
false |
| 246 |
|
| 247 |
- name: Re-run failed tests |
| 248 |
timeout-minutes: 10 |
| 249 |
if: steps.test.outcome == 'failure' && steps.test.outputs.finished == 'true' |
| 250 |
run: | |
| 251 |
# re-run failed tests providing that they didn't time out first time |
| 252 |
# TODO: make the tests deterministic so we don't need to do this |
| 253 |
etc/bin/run-functional-tests \ |
| 254 |
-j 1 \ |
| 255 |
-v \ |
| 256 |
--state=save,failed $(cat test-file) |
| 257 |
|
| 258 |
- name: Copy cylc-run out of container |
| 259 |
if: failure() && steps.test.outcome == 'failure' && env.REMOTE_PLATFORM == 'true' |
| 260 |
run: | |
| 261 |
# pick the first host in the list |
| 262 |
host="$(cut -d ' ' -f 1 <<< "${{ matrix.platform }}")" |
| 263 |
# copy back the remote cylc-run dir |
| 264 |
rsync -av \ |
| 265 |
"${host}:/root/cylc-run/" \ |
| 266 |
"${HOME}/cylc-run/${host}/" |
| 267 |
|
| 268 |
- name: Debug |
| 269 |
if: failure() && steps.test.outcome == 'failure' |
| 270 |
timeout-minutes: 1 |
| 271 |
run: | |
| 272 |
find "$HOME/cylc-run" -name '*.err' -type f \ |
| 273 |
-exec echo \; -exec echo '====== {} ======' \; -exec cat '{}' \; |
| 274 |
find "$HOME/cylc-run" -name '*.log' -type f \ |
| 275 |
-exec echo \; -exec echo '====== {} ======' \; -exec cat '{}' \; |
| 276 |
find "${TMPDIR:-/tmp}/${USER}/cylctb-"* -type f \ |
| 277 |
-exec echo \; -exec echo '====== {} ======' \; -exec cat '{}' \; |
| 278 |
|
| 279 |
- name: Set artifact upload name |
| 280 |
if: always() |
| 281 |
id: uploadname |
| 282 |
run: | |
| 283 |
# artifact name cannot contain '/' characters |
| 284 |
CID="$(sed 's|/|-|g' <<< "${{ matrix.name || matrix.chunk }}")" |
| 285 |
echo "uploadname=$CID" >> $GITHUB_OUTPUT |
| 286 |
|
| 287 |
- name: Upload failed tests artifact |
| 288 |
if: failure() && steps.test.outcome == 'failure' |
| 289 |
uses: actions/upload-artifact@v4 |
| 290 |
with: |
| 291 |
name: cylc-run (${{ steps.uploadname.outputs.uploadname }}) |
| 292 |
path: ~/cylc-run/ |
| 293 |
include-hidden-files: true |
| 294 |
|
| 295 |
- name: Fetch Remote Coverage |
| 296 |
if: env.REMOTE_PLATFORM == 'true' |
| 297 |
run: | |
| 298 |
# pick the first host in the list |
| 299 |
host="$(cut -d ' ' -f 1 <<< "${{ matrix.platform }}")" |
| 300 |
# copy back the remote coverage files |
| 301 |
rsync -av \ |
| 302 |
"${host}:/cylc/" \ |
| 303 |
'.' \ |
| 304 |
--include='.coverage*' \ |
| 305 |
--exclude='*' \ |
| 306 |
>rsyncout |
| 307 |
cat rsyncout |
| 308 |
# fiddle the python source location to match the local system |
| 309 |
for db in $(grep --color=never '.coverage\.' rsyncout); do |
| 310 |
sqlite3 "$db" " |
| 311 |
UPDATE file |
| 312 |
SET path = REPLACE(path, '/cylc/cylc/', '$PWD/cylc/') |
| 313 |
" |
| 314 |
done |
| 315 |
|
| 316 |
- name: Shutdown |
| 317 |
if: always() |
| 318 |
run: | |
| 319 |
etc/bin/swarm kill |
| 320 |
|
| 321 |
- name: Combine coverage & report |
| 322 |
run: | |
| 323 |
coverage combine -a |
| 324 |
coverage xml |
| 325 |
coverage report |
| 326 |
|
| 327 |
- name: Upload coverage artifact |
| 328 |
uses: actions/upload-artifact@v4 |
| 329 |
with: |
| 330 |
name: coverage_${{ steps.uploadname.outputs.uploadname }} |
| 331 |
path: coverage.xml |
| 332 |
retention-days: 7 |
| 333 |
|
| 334 |
codecov: |
| 335 |
needs: test |
| 336 |
runs-on: ubuntu-latest |
| 337 |
timeout-minutes: 2 |
| 338 |
steps: |
| 339 |
- name: Checkout |
| 340 |
uses: actions/checkout@v5 |
| 341 |
|
| 342 |
- name: Download coverage artifacts |
| 343 |
uses: actions/download-artifact@v5 |
| 344 |
|
| 345 |
- name: Codecov upload |
| 346 |
uses: codecov/codecov-action@v5 |
| 347 |
with: |
| 348 |
name: ${{ github.workflow }} |
| 349 |
flags: functional-tests |
| 350 |
fail_ci_if_error: true |
| 351 |
verbose: true |
| 352 |
# Token not required for public repos, but avoids upload failure due |
| 353 |
# to rate-limiting (but not for PRs opened from forks) |
| 354 |
token: ${{ secrets.CODECOV_TOKEN }} |