From 54b7da1202270fc565eb96f33ff19294c1127f58 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 26 Nov 2024 18:45:44 +0000 Subject: [PATCH 1/4] Make version check script more explicit Instead of calling ]up, it calls ]add Turing@, which more closely matches our intentions --- .github/workflows/version_check.jl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/version_check.jl b/.github/workflows/version_check.jl index f3ae7381d..f2277fb39 100644 --- a/.github/workflows/version_check.jl +++ b/.github/workflows/version_check.jl @@ -107,7 +107,12 @@ if ENV["TARGET_IS_MASTER"] == "true" println("$(MANIFEST_TOML_PATH) is out of date; updating") old_env = Pkg.project().path Pkg.activate(".") - Pkg.update() + try + Pkg.add(name="Turing", version=latest_version) + catch e + # If the Manifest couldn't be updated, the error will be shown later + println(e) + end # Check if versions match now, error if not Pkg.activate(old_env) manifest_toml = TOML.parsefile(MANIFEST_TOML_PATH) From 02fa4b19615f89091f90057bb966500b00acc8e6 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 26 Nov 2024 18:54:52 +0000 Subject: [PATCH 2/4] Fix version check GHA to not always show green tick --- .github/workflows/version_check.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/version_check.yml b/.github/workflows/version_check.yml index a8842d705..a434623ea 100644 --- a/.github/workflows/version_check.yml +++ b/.github/workflows/version_check.yml @@ -51,12 +51,11 @@ jobs: - name: Check version consistency id: version_check - continue-on-error: true run: julia --color=yes .github/workflows/version_check.jl - name: Create a PR with suggested changes id: create_pr - if: steps.version_check.outcome == 'failure' && env.TARGET_IS_MASTER && (! env.IS_PR_FROM_FORK) + if: always() && steps.version_check.outcome == 'failure' && env.TARGET_IS_MASTER && (! env.IS_PR_FROM_FORK) uses: peter-evans/create-pull-request@v6 with: base: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }} @@ -66,7 +65,7 @@ jobs: title: "Update Turing.jl version to match latest release" - name: Comment on PR about suggested changes (if PR was made) - if: github.event_name == 'pull_request' && steps.create_pr.outputs.pull-request-operation == 'created' + if: always() && github.event_name == 'pull_request' && steps.create_pr.outputs.pull-request-operation == 'created' uses: thollander/actions-comment-pull-request@v2 with: message: | From e745a7630ff647a9b762f48daa950aa61e351605 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 26 Nov 2024 19:08:33 +0000 Subject: [PATCH 3/4] Separate preview + remove-preview workflows --- .github/workflows/preview.yml | 36 ++++------------------------ .github/workflows/remove_preview.yml | 31 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/remove_preview.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 15f35b84c..94c24fd2a 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -10,6 +10,10 @@ on: concurrency: group: docs +permissions: + contents: write + pull-requests: write + jobs: build-and-preview: if: github.event.action == 'opened' || github.event.action == 'synchronize' @@ -70,12 +74,7 @@ jobs: commit-message: Deploy preview for PR ${{ github.event.pull_request.number }} token: ${{ secrets.GITHUB_TOKEN }} - comment-preview-url: - needs: build-and-preview - if: needs.build-and-preview.result == 'success' - runs-on: ubuntu-latest - steps: - - name: Comment Preview URL + - name: Comment preview URL uses: thollander/actions-comment-pull-request@v2 with: message: | @@ -83,28 +82,3 @@ jobs: Preview the changes: https://turinglang.org/docs/pr-previews/${{ github.event.pull_request.number }} Please avoid using the search feature and navigation bar in PR previews! comment_tag: preview-url-comment - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - delete-preview-directory: - if: github.event.action == 'closed' || github.event.pull_request.merged == true - runs-on: ubuntu-latest - steps: - - name: Checkout gh-pages branch - uses: actions/checkout@v4 - with: - ref: gh-pages - - - name: Remove PR Preview Directory - run: | - PR_NUMBER=${{ github.event.pull_request.number }} - PREVIEW_DIR="pr-previews/${PR_NUMBER}" - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git pull origin gh-pages - rm -rf ${PREVIEW_DIR} - git add . - git commit -m "Remove preview for merged PR #${PR_NUMBER}" - git push - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/remove_preview.yml b/.github/workflows/remove_preview.yml new file mode 100644 index 000000000..40f67e619 --- /dev/null +++ b/.github/workflows/remove_preview.yml @@ -0,0 +1,31 @@ +name: Remove PR previews + +on: + pull_request_target: + types: + - closed + +permissions: + contents: write + +jobs: + delete-preview-directory: + if: github.event.action == 'closed' || github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - name: Checkout gh-pages branch + uses: actions/checkout@v4 + with: + ref: gh-pages + + - name: Remove PR Preview Directory + run: | + PR_NUMBER=${{ github.event.pull_request.number }} + PREVIEW_DIR="pr-previews/${PR_NUMBER}" + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git pull origin gh-pages + rm -rf ${PREVIEW_DIR} + git add . + git commit -m "Remove preview for merged PR #${PR_NUMBER}" + git push From 3404f833ee4515ef17a5e1d5f56a957e14db9e68 Mon Sep 17 00:00:00 2001 From: Penelope Yong Date: Tue, 26 Nov 2024 19:16:28 +0000 Subject: [PATCH 4/4] Don't run preview on closed PRs --- .github/workflows/preview.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 94c24fd2a..b33926c08 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -5,7 +5,6 @@ on: types: - opened - synchronize - - closed concurrency: group: docs