Skip to content

Commit b7d983f

Browse files
authored
Fix GHA stuff (#563)
* Make version check script more explicit Instead of calling ]up, it calls ]add Turing@<desired_version>, which more closely matches our intentions * Fix version check GHA to not always show green tick * Separate preview + remove-preview workflows * Don't run preview on closed PRs
1 parent 8911dac commit b7d983f

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

.github/workflows/preview.yml

+5-32
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ on:
55
types:
66
- opened
77
- synchronize
8-
- closed
98

109
concurrency:
1110
group: docs
1211

12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
1316
jobs:
1417
build-and-preview:
1518
if: github.event.action == 'opened' || github.event.action == 'synchronize'
@@ -70,41 +73,11 @@ jobs:
7073
commit-message: Deploy preview for PR ${{ github.event.pull_request.number }}
7174
token: ${{ secrets.GITHUB_TOKEN }}
7275

73-
comment-preview-url:
74-
needs: build-and-preview
75-
if: needs.build-and-preview.result == 'success'
76-
runs-on: ubuntu-latest
77-
steps:
78-
- name: Comment Preview URL
76+
- name: Comment preview URL
7977
uses: thollander/actions-comment-pull-request@v2
8078
with:
8179
message: |
8280
<!-- preview-url-comment -->
8381
Preview the changes: https://turinglang.org/docs/pr-previews/${{ github.event.pull_request.number }}
8482
Please avoid using the search feature and navigation bar in PR previews!
8583
comment_tag: preview-url-comment
86-
env:
87-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88-
89-
delete-preview-directory:
90-
if: github.event.action == 'closed' || github.event.pull_request.merged == true
91-
runs-on: ubuntu-latest
92-
steps:
93-
- name: Checkout gh-pages branch
94-
uses: actions/checkout@v4
95-
with:
96-
ref: gh-pages
97-
98-
- name: Remove PR Preview Directory
99-
run: |
100-
PR_NUMBER=${{ github.event.pull_request.number }}
101-
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
102-
git config --global user.name "github-actions[bot]"
103-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
104-
git pull origin gh-pages
105-
rm -rf ${PREVIEW_DIR}
106-
git add .
107-
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
108-
git push
109-
env:
110-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/remove_preview.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Remove PR previews
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
delete-preview-directory:
13+
if: github.event.action == 'closed' || github.event.pull_request.merged == true
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout gh-pages branch
17+
uses: actions/checkout@v4
18+
with:
19+
ref: gh-pages
20+
21+
- name: Remove PR Preview Directory
22+
run: |
23+
PR_NUMBER=${{ github.event.pull_request.number }}
24+
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
25+
git config --global user.name "github-actions[bot]"
26+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
27+
git pull origin gh-pages
28+
rm -rf ${PREVIEW_DIR}
29+
git add .
30+
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
31+
git push

.github/workflows/version_check.jl

+6-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,12 @@ if ENV["TARGET_IS_MASTER"] == "true"
107107
println("$(MANIFEST_TOML_PATH) is out of date; updating")
108108
old_env = Pkg.project().path
109109
Pkg.activate(".")
110-
Pkg.update()
110+
try
111+
Pkg.add(name="Turing", version=latest_version)
112+
catch e
113+
# If the Manifest couldn't be updated, the error will be shown later
114+
println(e)
115+
end
111116
# Check if versions match now, error if not
112117
Pkg.activate(old_env)
113118
manifest_toml = TOML.parsefile(MANIFEST_TOML_PATH)

.github/workflows/version_check.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ jobs:
5151
5252
- name: Check version consistency
5353
id: version_check
54-
continue-on-error: true
5554
run: julia --color=yes .github/workflows/version_check.jl
5655

5756
- name: Create a PR with suggested changes
5857
id: create_pr
59-
if: steps.version_check.outcome == 'failure' && env.TARGET_IS_MASTER && (! env.IS_PR_FROM_FORK)
58+
if: always() && steps.version_check.outcome == 'failure' && env.TARGET_IS_MASTER && (! env.IS_PR_FROM_FORK)
6059
uses: peter-evans/create-pull-request@v6
6160
with:
6261
base: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}
@@ -66,7 +65,7 @@ jobs:
6665
title: "Update Turing.jl version to match latest release"
6766

6867
- name: Comment on PR about suggested changes (if PR was made)
69-
if: github.event_name == 'pull_request' && steps.create_pr.outputs.pull-request-operation == 'created'
68+
if: always() && github.event_name == 'pull_request' && steps.create_pr.outputs.pull-request-operation == 'created'
7069
uses: thollander/actions-comment-pull-request@v2
7170
with:
7271
message: |

0 commit comments

Comments
 (0)