-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger docs only when something inside the docs folder changed (#2587)
* Adding a check to see if there is any changes in the doc directory * Updating branch name * Changing condition * Adding a print statement for debugging purposes Printing exit code fixing if condition Changing exit code * Adding a print statement * changing the condition * Reversing conditions * Shifting check for change condition at the beginning * Fixing conditions * Changing print statements * Fixing logic for displaying docs * Stopping steps if no changes are detected * Stopping update environment step * Building docs only when changes are detected * Printing number of files changed * Counting files inside if condition * Changing check condition * Updating depth level * Update build-docs.yml * Removing debugging statement * Fixing errors * Updating message * Changing the condition to run the workflow * Create separate step for each condition * Fixing step for checking build docs label * Fixing error on the build docs label check * Adding a check to see if labels exist on a pr or not * Removing script from build docs label check * Running the set environment step conditionally * Updating conditions to run various steps * Adding workflow dispatch in the conditions to run the workflow * Adding contion to the update environment step * Splitting check and building docs in two jobs * Commenting out benchmarks workflow * Adding outcomes for both conditions * Using the right variables for needs outcome * Updating condition for running build docs * Add cloning repo and checking out the PR to the second job * Updating regex pattern * Resolving merge conflicts * Removing redundant code * Uncommenting benchmarks workflow * Changing job name to lower case
- Loading branch information
1 parent
8d70aaa
commit 7e7069a
Showing
2 changed files
with
76 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: [email protected] | ||
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/[email protected] | ||
|
@@ -141,7 +141,7 @@ jobs: | |
id: asv_pr_vs_master_changed | ||
uses: juliangruber/[email protected] | ||
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: | |
``` | ||
</details> | ||
All benchmarks: | ||
<details> | ||
|
@@ -184,7 +184,7 @@ jobs: | |
</details> | ||
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 | ||
asv-compare-changed-output.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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: '[email protected]' | ||
user_name: "TARDIS Bot" | ||
user_email: "[email protected]" | ||
|
||
- 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 | ||
|