-
Notifications
You must be signed in to change notification settings - Fork 0
#1: validate required workflows usage across repositories #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 18 commits
41e2354
49253d3
994ea16
f5569a8
fc790b1
13a8565
64c76b3
db017eb
3e43c5f
8cb99f1
e85bf50
a55151e
9f7e788
9e93329
07323a6
f4f8815
39dabba
6b589f1
a71e1d2
fbecf8c
08e349e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,6 @@ on: | |
| push: | ||
| branches: | ||
| - master | ||
| pull_request: | ||
| branches: "*" | ||
|
|
||
| jobs: | ||
| get-matrix: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| name: DARMA repositories check | ||
|
|
||
| # Run on the first day of the month | ||
| on: | ||
| schedule: | ||
| - cron: '0 0 1 * *' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.event.repository.name }}-${{ github.ref }}-${{ github.workflow }} | ||
| cancel-in-progress: True | ||
|
|
||
| jobs: | ||
| list_repositories: | ||
| name: List repositories | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: List repositories | ||
| id: list-repositories | ||
| run: | | ||
| REPOSITORIES=$(bash ci/list_repositories.sh) | ||
| echo "repositories=$(echo $REPOSITORIES)" >> $GITHUB_OUTPUT | ||
| outputs: | ||
| repositories: ${{ steps.list-repositories.outputs.repositories }} | ||
|
|
||
| check_repository: | ||
| name: Check repository (${{ matrix.repository.name }}) | ||
| runs-on: ubuntu-latest | ||
| needs: list_repositories | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| repository: ${{ fromJson(needs.list_repositories.outputs.repositories ) }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Check repositories | ||
| run: | | ||
| bash ./ci/check_repository.sh ${{ matrix.repository.name }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "problemMatcher": [ | ||
| { | ||
| "owner": "shell-error", | ||
| "severity": "error", | ||
| "pattern": [ | ||
| { | ||
| "regexp": "^[error]:\\s(.+)$" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "owner": "shell-warning", | ||
| "severity": "warning", | ||
| "pattern": [ | ||
| { | ||
| "regexp": "^[warning]:\\s(.+)$" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "owner": "shell-notice", | ||
| "severity": "notice", | ||
| "pattern": [ | ||
| { | ||
| "regexp": "^[notice]:\\s(.+)$" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| __pycache__ | ||
| __pycache__ | ||
| ci/repositories.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Check that a repository is compliant: | ||
| # - all expected workflows are present | ||
|
|
||
| CURRENT_DIR="$(dirname -- "$(realpath -- "$0")")" # Current directory | ||
| PARENT_DIR="$(dirname "$CURRENT_DIR")" | ||
| WORKING_DIR="$PARENT_DIR/output" | ||
| ORG=DARMA-tasking | ||
| REPOSITORY=$1 | ||
| EXPECTED_WORKFLOWS=( \ | ||
| find-unsigned-commits \ | ||
| check-commit-format \ | ||
| find-trailing-whitespace \ | ||
| check-pr-fixes-issue \ | ||
| action-git-diff-check \ | ||
| ) | ||
|
|
||
| # Clean | ||
| rm -rf $WORKING_DIR | ||
| mkdir -p $WORKING_DIR | ||
|
|
||
| # Initialize | ||
| N_ERRORS=0 | ||
| TSSTART=$(date +%s) | ||
| echo "$ORG/$REPOSITORY > Cloning repository..."; | ||
| git clone https://github.com/$ORG/$REPOSITORY $WORKING_DIR/$REPOSITORY >/dev/null 2>&1 | ||
|
|
||
| # Directory containing workflow files | ||
| WORKFLOWS_DIR="$WORKING_DIR/$REPOSITORY/.github/workflows" | ||
| FOUND_WORKFLOWS=() | ||
|
|
||
| # Check workflows | ||
| if [ ! -d "$WORKFLOWS_DIR" ]; then | ||
| echo "[error] Workflow directory '$WORKFLOWS_DIR' does not exist." | ||
| exit 1 | ||
| fi | ||
|
|
||
| for file in "$WORKFLOWS_DIR"/*.yml; do | ||
| if [ ! -f "$file" ]; then | ||
| continue | ||
| fi | ||
|
|
||
| # Check each file for the current workflow | ||
| for w in "${EXPECTED_WORKFLOWS[@]}"; do | ||
| if grep -qE "uses: .*/$w" "$file"; then | ||
| if [[ ! " ${FOUND_WORKFLOWS[@]} " =~ " $w " ]]; then | ||
| FOUND_WORKFLOWS+=("$w") | ||
| echo "[ok] Found workflow '$w' in file '${file#$WORKING_DIR/}'" | ||
| fi | ||
| fi | ||
| done | ||
|
|
||
| # Exit if all workflows are found | ||
| if [ ${#FOUND_WORKFLOWS[@]} -eq ${#EXPECTED_WORKFLOWS[@]} ]; then | ||
| break | ||
| fi | ||
| done | ||
|
|
||
| # Ensure all workflows were found | ||
| if [ ${#FOUND_WORKFLOWS[@]} -ne ${#EXPECTED_WORKFLOWS[@]} ]; then | ||
| echo "[error] Missing workflows:" | ||
| for w in "${EXPECTED_WORKFLOWS[@]}"; do | ||
| if [[ ! " ${FOUND_WORKFLOWS[@]} " =~ " $w " ]]; then | ||
| echo " - $w" | ||
| ((N_ERRORS++)) | ||
| fi | ||
| done | ||
| else | ||
| echo "[ok] All expected workflows are present." | ||
| fi | ||
|
|
||
| # Finalize | ||
| TSEND=$(date +%s) | ||
| TSDURATION=$(( $TSEND - $TSSTART )) | ||
| if [[ $N_ERRORS -gt 0 ]] | ||
| then | ||
| echo "$WORKING_DIR/$REPOSITORY has $N_ERRORS errors." | ||
| else | ||
| echo "[success] repository checks OK." | ||
| fi | ||
| echo "$WORKING_DIR/$REPOSITORY has been processed in $TSDURATION seconds." | ||
| echo "--------------------------------------------------"; | ||
|
|
||
| if [[ $N_ERRORS -gt 0 ]] | ||
| then | ||
| exit 1 | ||
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/bash | ||
|
|
||
| # List the repositories in the DARMA-tasking organization - in JSON format - | ||
| # that need to be checked | ||
|
|
||
| ORG=DARMA-tasking | ||
| EXCLUDE='[ | ||
| "DARMA-tasking.github.io", | ||
| "find-unsigned-commits", | ||
| "check-commit-format", | ||
| "find-trailing-whitespace", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is trailing WS finder excluded?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| "check-pr-fixes-issue", | ||
| "vt-sample-project", | ||
| "parallel-for-transformer", | ||
| "detector", | ||
| "workflows" | ||
| ]' | ||
| JQ="$EXCLUDE as \$blacklist | .[] | select(.isFork | not) | select(.name as \$in | \$blacklist | index(\$in) | not)" | ||
| gh repo list $ORG --json name,defaultBranchRef,isFork --jq "$JQ" | jq -s 'sort_by(.name)' | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by the
cronvalues, could you put a comment to explain them for future reference? ThanksThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment; let me know if it is clear now.