Skip to content

Commit

Permalink
#1: check contents of workflows and cancel existing jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
cwschilly committed Jan 6, 2025
1 parent db017eb commit 3e43c5f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/check-repositories.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
name: DARMA repositories check

on:
# schedule:
# schedule:
# - cron: '*/30 * * * *'
push:
branches:
- 1-validate-required-workflows-usage-across-repositories

concurrency:
group: ${{ github.event.repository.name }}-${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: True

jobs:
list_repositories:
name: List repositories
Expand All @@ -15,7 +19,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4

- name: List repositories
id: list-repositories
run: |
Expand All @@ -36,9 +40,6 @@ jobs:
repository: ${{ fromJson(needs.list_repositories.outputs.repositories ) }}
steps:
- uses: actions/checkout@v4

- name: Check repositories
run: |
bash ./ci/check_repository.sh ${{ matrix.repository.name }}
15 changes: 10 additions & 5 deletions ci/check_repository.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

# Check that a repository is compliant:
# - required workflows exist
# - required file exists
# - file uses the correct workflow

CURRENT_DIR="$(dirname -- "$(realpath -- "$0")")" # Current directory
PARENT_DIR="$(dirname "$CURRENT_DIR")"
Expand All @@ -26,16 +27,20 @@ TSSTART=$(date +%s)
echo "$ORG/$REPOSITORY > Cloning repository...";
git clone https://github.com/$ORG/$REPOSITORY $WORKING_DIR/$REPOSITORY >/dev/null 2>&1

# Ckeck workflows (files exist as expected)
# Ckeck workflows (files exist as expected and contain correct workflow)
for w in "${EXPECTED_WORKFLOWS[@]}"
do
if [ ! -f "$WORKING_DIR/$REPOSITORY/.github/workflows/$w.yml" ]; then
echo "[error] Missing workflow file '$w.yml' at $WORKING_DIR/$REPOSITORY/.github/workflows/$w.yml"
((N_ERRORS++))
else
echo "[ok] workflow file '$w.yml' OK"
# ENHANCEMENT: check that file is calling the appropriate workflow
# (read yaml file and find the use statement)
# Check that the correct workflow is used
if [ ! grep -q "uses: DARMA-tasking/$w" "$WORKFLOW_FILE" ]; then
echo "[error] Workflow file '$w.yml' does not contain 'uses: DARMA-tasking/$w'"
((N_ERRORS++))
else
echo "[ok] workflow file '$w.yml is correct"
fi
fi
done

Expand Down
2 changes: 1 addition & 1 deletion ci/list_repositories.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# List the repositories in the DARMA-tasking organization - in JSON format -
# List the repositories in the DARMA-tasking organization - in JSON format -
# that need to be checked

ORG=DARMA-tasking
Expand Down

0 comments on commit 3e43c5f

Please sign in to comment.