diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index 126859dbc19..5088149cd78 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -27,10 +27,10 @@ defaults: jobs: build: if: github.repository_owner == 'tardis-sn' && - (github.event_name == 'push' || - github.event_name == 'workflow_dispatch' || - (github.event_name == 'pull_request_target' && - contains(github.event.pull_request.labels.*.name, 'benchmarks'))) + (github.event_name == 'push' || + github.event_name == 'workflow_dispatch' || + (github.event_name == 'pull_request_target' && + contains(github.event.pull_request.labels.*.name, 'benchmarks'))) runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -44,7 +44,7 @@ jobs: ref: ${{ github.sha }} fetch-depth: 0 if: github.event_name == 'pull_request_target' - + - name: Restore Atom Data uses: actions/cache/restore@v3 id: atom-data-restore @@ -65,7 +65,7 @@ jobs: with: path: benchmarks/data/kurucz_cd23_chianti_H_He.h5 key: atom-data - + - name: Setup Mamba uses: mamba-org/setup-micromamba@v1 with: @@ -82,7 +82,7 @@ jobs: - name: Accept all asv questions run: asv machine --yes - + - name: Run benchmarks for last 5 commits if not PR if: github.event_name != 'pull_request_target' run: | @@ -96,11 +96,11 @@ jobs: - name: Generate Graphs and HTML if: github.event_name != 'pull_request_target' run: asv publish - + - name: Delete env files if: github.event_name != 'pull_request_target' run: rm -r .asv/env - + - name: Push results to results repository if: github.event_name != 'pull_request_target' continue-on-error: true @@ -114,7 +114,7 @@ jobs: user-email: tardis.sn.bot@gmail.com target-branch: main target-directory: .asv - + - name: Compare HEAD with master if PR if: github.event_name == 'pull_request_target' continue-on-error: true # TODO: step failed sporadically while testing @@ -124,13 +124,13 @@ jobs: echo "Some benchmarks have errors!" exit 1 fi - + - name: Compare Master and PR head - run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tee asv-compare-output.log - + run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tee asv-compare-output.log + - name: Compare Master and PR head but only show changed results - run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --only-changed | tee asv-compare-changed-output.log - + run: asv compare ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} --only-changed | tee asv-compare-changed-output.log + - name: Benchmarks compare output id: asv_pr_vs_master uses: juliangruber/read-file-action@v1.0.0 @@ -141,7 +141,7 @@ jobs: id: asv_pr_vs_master_changed uses: juliangruber/read-file-action@v1.0.0 with: - path: asv-compare-changed-output.log + path: asv-compare-changed-output.log - name: Find Comment if: always() && github.event_name == 'pull_request_target' @@ -155,7 +155,7 @@ jobs: if: github.event_name == 'pull_request_target' uses: peter-evans/create-or-update-comment@v2 with: - token: ${{ secrets.BOT_TOKEN }} + token: ${{ secrets.BOT_TOKEN }} issue-number: ${{ github.event.number }} comment-id: ${{ steps.fc.outputs.comment-id }} edit-mode: replace @@ -173,7 +173,7 @@ jobs: ``` - + All benchmarks:
@@ -184,7 +184,7 @@ jobs:
env: URL: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }}?check_suite_focus=true - + - name: Save results artifact uses: actions/upload-artifact@v3 if: always() @@ -194,6 +194,4 @@ jobs: .asv/results asv-cont-output.log asv-compare-output.log - asv-compare-changed-output.log - - \ No newline at end of file + asv-compare-changed-output.log diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index a216a6a5c6f..a36a2e802b4 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -5,7 +5,6 @@ name: docs on: - push: branches: - master @@ -18,14 +17,14 @@ on: - opened - reopened - synchronize - - labeled # requires the `build-docs` label + - labeled # requires the `build-docs` label - workflow_dispatch: # manual trigger + workflow_dispatch: # manual trigger env: - CACHE_NUMBER: 0 # increase to reset cache manually - DEPLOY_BRANCH: gh-pages # deployed docs branch - HDF5_USE_FILE_LOCKING: 'FALSE' # disable file locking + CACHE_NUMBER: 0 # increase to reset cache manually + DEPLOY_BRANCH: gh-pages # deployed docs branch + HDF5_USE_FILE_LOCKING: "FALSE" # disable file locking concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} @@ -36,31 +35,65 @@ defaults: shell: bash -l {0} jobs: - build-docs: + check-for-changes: + runs-on: ubuntu-latest + outputs: + trigger-check-outcome: ${{ steps.trigger_check.outcome }} + docs-check-outcome: ${{ steps.docs_check.outcome }} + steps: + - uses: actions/checkout@v4 + if: github.event_name != 'pull_request_target' - if: github.event_name == 'push' || - github.event_name == 'workflow_dispatch' || - (github.event_name == 'pull_request_target' && - contains(github.event.pull_request.labels.*.name, 'build-docs')) + - name: Checkout pull/${{ github.event.number }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + if: github.event_name == 'pull_request_target' + + - name: Check for trigger by push event, manual dispatch, build-docs label on a PR + id: trigger_check + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'build-docs') + run: | + echo "Building docs as a test." + exit 0 + continue-on-error: true + - name: Check for changes in documentation + run: | + if git diff origin/master..."$(git rev-parse --abbrev-ref HEAD)" --name-only | cat | grep '^docs/' | grep -q .; then + num_files=$(git diff --name-only origin/master...HEAD | grep '^docs/' | wc -l) + echo "Changes found in documentation files: $num_files" + exit 0 + else + echo "No changes found in documentation files - will stop running the pipeline." + exit 1 + fi + id: docs_check + if: steps.trigger_check.outcome != 'success' + continue-on-error: true + + build-docs: runs-on: ubuntu-latest + needs: check-for-changes + if: needs.check-for-changes.outputs.trigger-check-outcome == 'success' || needs.check-for-changes.outputs.docs-check-outcome == 'success' steps: - - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 if: github.event_name != 'pull_request_target' - name: Checkout pull/${{ github.event.number }} - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: - ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} if: github.event_name == 'pull_request_target' - name: Generate Cache Key - run: | + run: | file_hash=$(cat conda-linux-64.lock | shasum -a 256 | cut -d' ' -f1) echo "file_hash=$file_hash" >> "${GITHUB_OUTPUT}" id: cache-environment-key - + - uses: mamba-org/setup-micromamba@v1 with: environment-file: conda-linux-64.lock @@ -125,8 +158,8 @@ jobs: destination_dir: ${{ env.DEST_DIR }} keep_files: true force_orphan: ${{ env.CLEAN_BRANCH }} - user_name: 'TARDIS Bot' - user_email: 'tardis.sn.bot@gmail.com' + user_name: "TARDIS Bot" + user_email: "tardis.sn.bot@gmail.com" - name: Find comment uses: peter-evans/find-comment@v1 @@ -139,7 +172,7 @@ jobs: - name: Post comment (success) uses: peter-evans/create-or-update-comment@v1 with: - token: ${{ secrets.BOT_TOKEN }} + token: ${{ secrets.BOT_TOKEN }} issue-number: ${{ github.event.number }} comment-id: ${{ steps.fc.outputs.comment-id }} edit-mode: replace @@ -149,7 +182,7 @@ jobs: Hi, human. The **`${{ github.workflow }}`** workflow has **succeeded** :heavy_check_mark: - + [**Click here**](${{ env.URL }}) to see your results. env: URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/pull/${{ github.event.number }}/index.html @@ -158,7 +191,7 @@ jobs: - name: Post comment (failure) uses: peter-evans/create-or-update-comment@v1 with: - token: ${{ secrets.BOT_TOKEN }} + token: ${{ secrets.BOT_TOKEN }} issue-number: ${{ github.event.number }} comment-id: ${{ steps.fc.outputs.comment-id }} edit-mode: replace @@ -168,7 +201,7 @@ jobs: Hi, human. The **`${{ github.workflow }}`** workflow has **failed** :x: - + [**Click here**](${{ env.URL }}) to see the build log. env: URL: https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }}?check_suite_focus=true