-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
attempt to rebuild vignettes on label (#137)
* attempt to rebuild vignettes on label. Addresses #50 * renamed the label * use abn containers as basis. * fixed env was defined twice. * push to current branch * changed branch name to github branch name. * using repo scope token * changed git user to abn-cicd-helper bot * try commit and push with GH action... * try again with the push action * Revert "changed git user to abn-cicd-helper bot" This reverts commit a1396d7. * added directory as safe to fix dubious ownership warning. * removed push origin * use gh cli to checkout PR * in container gh must be installed. On standart runners it would be by default. * add specific sysreqs for INLA installation * added github token to env * add safe directory before checkout of PR * Automated Vignette Compilation * fix mess * commit only recompiled vignettes but nothing else * commit only recompiled vignettes but nothing else * fixed divergent histories * need to install abn package with the newest r-containers! * Automated Vignette Compilation * commit everything within vignettes directory * debugging git add * fix image location * typo * debugging adding png * typo * Automated Vignette Compilation * place plots in the correct folder * removed wrongly placed figures * Automated Vignette Compilation * move them, not copy! * Automated Vignette Compilation * updated interpretation of benchmark plot --------- Co-authored-by: GitHub Vignette Bot <[email protected]>
- Loading branch information
1 parent
236ec8a
commit 4279bc3
Showing
10 changed files
with
234 additions
and
36 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 |
---|---|---|
@@ -0,0 +1,197 @@ | ||
# Workflow triggered when we have a new release candidate | ||
# This action is adapted from https://github.com/t4d-gmbh/stubbed_versioning | ||
name: On Label rebuild vignettes | ||
|
||
on: | ||
pull_request: | ||
types: [ labeled ] | ||
|
||
env: | ||
LABEL_CHECK: 'CompVignettes::build' | ||
LABEL_SUCCESS: 'CompVignettes::passed' | ||
LABEL_FAILURE: 'CompVignettes::failed' | ||
DOC_LOC: "./docs" | ||
BRANCH: ${{ github.head_ref || github.ref_name }} | ||
|
||
jobs: | ||
set_target: | ||
if: ${{ github.event.label.name == 'CompVignettes::build' }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
label: ${{ steps.set_label.outputs.label }} | ||
steps: | ||
- id: set_label | ||
run: | | ||
echo "label=${{ env.LABEL_CHECK }}" >> "$GITHUB_OUTPUT" | ||
check_label_exist: | ||
needs: | ||
- set_target | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- name: Assert labels ${{ env.LABEL_CHECK }} is defined | ||
run: | | ||
gh label create ${{ env.LABEL_CHECK }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
continue-on-error: true # make sure the next steps run also on failure | ||
- name: Assert labels ${{ env.LABEL_SUCCESS }} is defined | ||
run: | | ||
gh label create ${{ env.LABEL_SUCCESS }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
continue-on-error: true # make sure the next steps run also on failure | ||
- name: Assert labels ${{ env.LABEL_FAILURE }} is defined | ||
run: | | ||
gh label create ${{ env.LABEL_FAILURE }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
continue-on-error: true # make sure the next steps run also on failure | ||
|
||
vignette_build: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- set_target | ||
container: | ||
image: ${{ vars.CONTAINER_SOURCE }}/${{ matrix.os }}/${{ matrix.compiler }}/${{ matrix.r-version }}/abn:${{ vars.CONTAINER_VERSION || 'latest' }} | ||
credentials: | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
env: | ||
R_KEEP_PKG_SOURCE: yes # NOTE Jo: not sure why this is here? | ||
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
EVENT: ${{ github.event.number }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
r-version: ['release'] | ||
os: ['debian'] | ||
compiler: ['gcc'] | ||
permissions: | ||
contents: write | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Checkout branch of PR | ||
run: | | ||
apt-get update && apt-get install -y gh | ||
git config --global --add safe.directory /__w/abn/abn | ||
gh pr checkout ${{ env.EVENT }} | ||
- name: Disable renv | ||
run: | | ||
renv::deactivate() | ||
shell: Rscript {0} | ||
- name: Configure ABN for installation | ||
run: | | ||
autoreconf | ||
- name: Install package dependencies | ||
run: | | ||
devtools::install_deps(pkg = '.', dependencies = TRUE, upgrade='never') | ||
shell: Rscript {0} | ||
- name: Install ABN | ||
run: | | ||
R CMD INSTALL . | ||
- name: Rebuild Vignettes | ||
run: | | ||
source("vignettes/precompile.R") | ||
shell: Rscript {0} | ||
- name: Copy Figures to Vignettes folder | ||
run: | | ||
mv ./*.png vignettes/ | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
path: vignettes/ | ||
- name: Commit compiled vignettes to branch | ||
run: | | ||
git config --global user.name 'GitHub Vignette Bot' | ||
git config --global user.email '[email protected]' | ||
git config --global --add safe.directory /__w/abn/abn | ||
git add vignettes/ | ||
git add *.png | ||
git commit -m "Automated Vignette Compilation" | ||
git push | ||
report_vignette_build: | ||
if: ${{ (success() || failure()) }} | ||
needs: | ||
- vignette_build | ||
- check_label_exist | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
repository-projects: write | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Check if on demand tasks succeeded | ||
run: | | ||
gh pr edit ${{ env.EVENT }} --remove-label ${{ env.LABEL_CHECK }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
if [ ${{ needs.vignette_build.result }} == "success" ]; then | ||
gh pr edit ${{ env.EVENT }} --remove-label ${{ env.LABEL_FAILURE }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
gh pr edit ${{ env.EVENT }} --add-label ${{ env.LABEL_SUCCESS }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
echo "### ${{ github.event.label.url }} passed! :rocket:" >> $GITHUB_STEP_SUMMARY | ||
exit 0 | ||
elif [ ${{ needs.vignette_build.result }} == "failure" ]; then | ||
gh pr edit ${{ env.EVENT }} --remove-label ${{ env.LABEL_SUCCESS }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
gh pr edit ${{ env.EVENT }} --add-label ${{ env.LABEL_FAILURE }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
echo "### ${{ github.event.label.url }} failed!" >> $GITHUB_STEP_SUMMARY | ||
exit 1 | ||
else | ||
gh pr edit ${{ env.EVENT }} --add-label ${{ env.LABEL_CHECK }} --repo ${{ env.OWNER }}/${{ env.REPO }} | ||
echo "On demand task outcome was ${{ steps.some_task.outcome }}" | ||
fi | ||
shell: bash | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
EVENT: ${{ github.event.number }} # This is either the issue or pr | ||
|
||
record_passed_label: | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
repository-projects: write | ||
outputs: | ||
passed: ${{ steps.passed.outputs.PASSED}} | ||
steps: | ||
- name: Check if the pull request is labeled with ${{ env.LABEL_SUCCESS }} # 2 | ||
id: passed | ||
run: | | ||
if $( gh pr view ${{ env.EVENT }} --repo ${{ env.OWNER }}/${{ env.REPO }} --json "labels" --jq ".[].[].name" | grep --quiet ${{ env.LABEL_SUCCESS }}); then | ||
echo "PASSED=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "PASSED=false" >> $GITHUB_OUTPUT | ||
fi | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
EVENT: ${{ github.event.number }} # This is either the issue or pr | ||
|
||
vignette_build_passed: | ||
if: ${{ always() }} | ||
needs: | ||
- vignette_build | ||
- record_passed_label | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OWNER: ${{ github.repository_owner }} | ||
REPO: ${{ github.event.repository.name }} | ||
steps: | ||
- name: Assert that either job passed or the label is present | ||
run: | | ||
if [[ ${{ needs.vignette_build.result }} == 'success' || ${{ needs.record_passed_label.outputs.passed }} == 'true' ]]; then | ||
echo 'vignette_build status ok'; | ||
else exit 1; fi | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Oops, something went wrong.