Skip to content

Commit e9a0da1

Browse files
committed
[ci] Upload PR results always to new URLs
Otherwise, one might only see the cached versions and not the updated results. Refs pmd#5556
1 parent 7bbc9b3 commit e9a0da1

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

.github/workflows/publish-pull-requests.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ jobs:
5555
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_PMD_PULL_REQUESTS_SECRET_ACCESS_KEY }}
5656
AWS_DEFAULT_REGION: eu-central-1
5757
run: |
58-
aws s3 sync docs-artifact "s3://pmd-pull-requests/pr-${PR_NUMBER}/docs" --no-progress
59-
echo "public url: https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/docs"
58+
aws s3 sync docs-artifact "s3://pmd-pull-requests/pr-${PR_NUMBER}/${PR_SHA}/docs" --no-progress
59+
echo "public url: https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/${PR_SHA}/docs"
6060
- name: Add commit status (Documentation)
6161
env:
6262
# Token required for GH CLI:
@@ -67,7 +67,7 @@ jobs:
6767
-H "Accept: application/vnd.github+json" \
6868
-H "X-GitHub-Api-Version: 2022-11-28" \
6969
"/repos/pmd/pmd/statuses/${PR_SHA}" \
70-
-f "state=success" -f "target_url=https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/docs" \
70+
-f "state=success" -f "target_url=https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/${PR_SHA}/docs" \
7171
-f "description=PMD Documentation Preview" -f "context=Published Results / Documentation"
7272
- name: Add Check Status (Documentation)
7373
env:
@@ -82,7 +82,7 @@ jobs:
8282
/repos/pmd/pmd/check-runs \
8383
-f "name=Documentation" -f "head_sha=${PR_SHA}" -f "status=completed" \
8484
-f "started_at=${timestamp}" -f "conclusion=success" -f "completed_at=${timestamp}" \
85-
-f "output[title]=Documentation Preview" -f "output[summary]=[Documentation Preview](https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/docs)"
85+
-f "output[title]=Documentation Preview" -f "output[summary]=[Documentation Preview](https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/${PR_SHA}/docs)"
8686
8787
- name: Download pmd-regression-tester
8888
env:
@@ -100,8 +100,8 @@ jobs:
100100
AWS_DEFAULT_REGION: eu-central-1
101101
run: |
102102
if [ -e "pmd-regression-tester/index.html" ]; then
103-
aws s3 sync pmd-regression-tester "s3://pmd-pull-requests/pr-${PR_NUMBER}/regression" --no-progress
104-
echo "public url: https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/regression"
103+
aws s3 sync pmd-regression-tester "s3://pmd-pull-requests/pr-${PR_NUMBER}/${PR_SHA}/regression" --no-progress
104+
echo "public url: https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/${PR_SHA}/regression"
105105
echo "REGRESSION_REPORT_UPLOADED=1" >> "${GITHUB_ENV}"
106106
else
107107
echo "No report available."
@@ -118,7 +118,7 @@ jobs:
118118
-H "Accept: application/vnd.github+json" \
119119
-H "X-GitHub-Api-Version: 2022-11-28" \
120120
"/repos/pmd/pmd/statuses/${PR_SHA}" \
121-
-f "state=success" -f "target_url=https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/regression" \
121+
-f "state=success" -f "target_url=https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/${PR_SHA}/regression" \
122122
-f "description=PMD Regression Tester Report" -f "context=Published Results / Regression Tester"
123123
- name: Prepare regression summary
124124
run: |-
@@ -127,7 +127,7 @@ jobs:
127127
summary="
128128
${summary}
129129
130-
[Regression Tester Report](https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/regression)
130+
[Regression Tester Report](https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/${PR_SHA}/regression)
131131
"
132132
fi
133133
echo "${summary}" > pmd-regression-tester/summary.txt
@@ -153,7 +153,7 @@ jobs:
153153
- name: Prepare comment text
154154
run: |-
155155
summary="$(cat pmd-regression-tester/summary.txt)"
156-
comment="[Documentation Preview](https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/docs)
156+
comment="[Documentation Preview](https://pull-requests.pmd-code.org/pr-${PR_NUMBER}/${PR_SHA}/docs)
157157
158158
${summary}
159159
"

docs/pages/pmd/devdocs/github_actions_workflows.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ a commit status and check status to the PR and finally adds a PR comment.
7575
Both the "docs-artifact" and the "pmd-regression-tester" artifact are uploaded to an AWS S3 bucket
7676
called **pmd-pull-requests**. This bucket is served via AWS Cloudfront (for having TLS) under
7777
the URL <https://pull-requests.pmd-code.org>. Note, there is no directory listing. The results
78-
of each pull request are uploaded under the folder "pr-{PR_NUMBER}/docs" and "pr-{PR_NUMBER}/regression",
78+
of each pull request are uploaded under the folders "pr-{PR_NUMBER}/{PR_SHA}/docs" and "pr-{PR_NUMBER}/{PR_SHA}/regression",
7979
respectively. The data in the S3 bucket is available for 60 days, after that the files are removed
80-
(hopefully).
80+
automatically (hopefully). Since the head SHA of the PR is included in the URL, an updated PR will upload
81+
new versions of the artifacts. Otherwise, Cloudfront's cache might prevent us from seeing the
82+
updated artifacts.
8183

8284
In order to upload the files to AWS S3, we use the [AWS CLI](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3/index.html)
8385
tool, that is available on the GitHub provided runners for GitHub Actions. It needs the following **secrets**:

0 commit comments

Comments
 (0)