Skip to content

Workflows: reworked actions and ways to skip eamxx testing jobs #96

Workflows: reworked actions and ways to skip eamxx testing jobs

Workflows: reworked actions and ways to skip eamxx testing jobs #96

name: eamxx-scripts
on:
# Runs on PRs against master, but only if they touch eamxx scripts
pull_request:
branches: [ master ]
types: [opened, synchronize, ready_for_review, reopened]
# Manual run for debug purposes only
workflow_dispatch:
# Add schedule trigger for nightly runs at midnight MT (Standard Time)
schedule:
- cron: '0 7 * * *' # Runs at 7 AM UTC, which is midnight MT during Standard Time
concurrency:
# Two runs are in the same group if they are testing the same git ref
# - if trigger=pull_request, the ref is refs/pull/<PR_NUMBER>/merge
# - for other triggers, the ref is the branch tested
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
pr_relevant:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest # This job can run anywhere
outputs:
value: ${{ steps.check_paths.outputs.touched }}
steps:
- name: check_paths
paths=(

Check failure on line 31 in .github/workflows/eamxx-scripts-tests.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/eamxx-scripts-tests.yml

Invalid workflow file

You have an error in your yaml syntax on line 31
components/eamxx/scripts
components/eamxx/cime_config/eamxx
components/eamxx/cime_config/build
components/eamxx/cime_config/yaml_utils.py
.github/workflows/eamxx-scripts-tests.yml
)
pattern=$(IFS=\|; echo "${paths[*]}")
# Use the GitHub API to get the list of changed files
response=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}/files")
changed_files=$(echo "$response" | grep -o '"filename": *"[^"]*"' | sed 's/"filename": *//; s/"//g')
# Check for matches and echo the matching files (or "" if none)
matching_files=$(echo "$changed_files" | grep -E "^($pattern)" || echo "")
if [[ -n "$matching_files" ]]; then
echo "Found relevant files: $matching_files"
echo "touched=true" >> $GITHUB_OUTPUT
else
echo "No relevant files touched by this PR."
echo "touched=false" >> $GITHUB_OUTPUT
fi
get_labels:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
outputs:
labels: ${{ steps.get_labels.outputs.labels }}
steps:
- name: get_labels
run: |
labels_json=${{ toJson(github.event.pull_request.labels.*.name) }}
echo 'labels=\"$(echo \"$PR_LABELS\" | jq -r "join(\",\")")\"' >> $GITHUB_OUTPUT
cpu-gcc:
needs: [pr_relevant, get_labels]
# if: ${{
# github.event_name != 'pull_request' ||
# (
# needs.pr_relevant.outputs.value == 'true'
# # needs.pr_relevant.outputs.value == 'true' &&
# # !contains(split(needs.get_labels.outputs.labels, ','), 'CI: skip eamxx-all')
# )
# }}
runs-on: [self-hosted, gcc, ghci-snl-cpu]
steps:
- name: print-stuff
run: |
echo "PR Relevant Value: '${{ needs.pr_relevant.outputs.value }}'"
echo "Event Name: '${{ github.event_name }}'"
echo "labels: '${{ needs.get_labels.outputs.labels }}'"
- name: Check out the repository
uses: actions/checkout@v4
with:
persist-credentials: false
show-progress: false
submodules: recursive
- name: Show action trigger
uses: ./.github/actions/show-workflow-trigger
- name: Run test
run: |
cd components/eamxx
if [ ${{ github.event_name == 'schedule' }} ]; then
./scripts/scripts-ctest-driver -s -m ghci-snl-cpu
else
./scripts/scripts-tests -f -m ghci-snl-cpu
./scripts/cime-nml-tests
fi