Skip to content

Commit c3b8bcd

Browse files
committed
Test CTF with Gitpod.
1 parent 2eaf650 commit c3b8bcd

File tree

3 files changed

+55
-12
lines changed

3 files changed

+55
-12
lines changed

.github/workflows/compare-ds.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
repository: mildas/content-test-filtering
3535
path: ctf
3636
- name: Detect content changes in the PR
37-
run: python3 ./ctf/content_test_filtering.py pr --base ${{ steps.fork_point.outputs.FORK_POINT }} --verbose --rule --output json ${{ github.event.pull_request.number }} > output.json
37+
run: python3 ./ctf/content_test_filtering.py pr --base ${{ steps.fork_point.outputs.FORK_POINT }} --remote_repo ${{ github.server_url }}/${{ github.repository }} --verbose --rule --output json ${{ github.event.pull_request.number }} > output.json
3838
- name: Test if there are no content changes
3939
run: echo "::set-output name=CTF_OUTPUT_SIZE::$(stat --printf="%s" output.json)"
4040
id: ctf

.github/workflows/ctf.yaml

Lines changed: 53 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Gating
22
on:
3-
pull_request:
3+
pull_request_target:
44
branches: [ master, 'stabilization*' ]
55
jobs:
66
content-test-filtering:
@@ -11,26 +11,69 @@ jobs:
1111
uses: mstksg/get-package@master
1212
with:
1313
apt-get: git python3-jinja2 python3-yaml python3-setuptools python3-deepdiff python3-git python3-github python3-requests xmldiff
14-
# TODO: Use action's checkout along with --local and --repository options of ctf
15-
# See: https://github.community/t/how-to-commit-to-two-branches-from-an-action/17713/4
1614
- name: Checkout
1715
uses: actions/checkout@v2
1816
with:
17+
ref: ${{ github.event.pull_request.head.sha }}
1918
fetch-depth: 0
2019
- name: Find forking point
2120
env:
2221
BASE_BRANCH: ${{ github.base_ref }}
2322
run: echo "::set-output name=FORK_POINT::$(git merge-base origin/$BASE_BRANCH ${{ github.event.pull_request.head.sha }})"
2423
id: fork_point
24+
- name: Checkout fork point
25+
uses: actions/checkout@v2
26+
with:
27+
ref: ${{ steps.fork_point.outputs.FORK_POINT }}
28+
fetch-depth: 0
2529
- name: Checkout (CTF)
2630
uses: actions/checkout@v2
2731
with:
2832
repository: mildas/content-test-filtering
2933
path: ctf
30-
- name: Process (see the output for recommended tests)
31-
run: python3 ./ctf/content_test_filtering.py pr --base ${{ steps.fork_point.outputs.FORK_POINT }} --verbose --output-format markdown ${{ github.event.pull_request.number }} # > ctf.md
32-
# TODO: We can't do this for now: github.token is incapable of writing to the PR, and we can't provide our own
33-
# for PRs coming from forked repos
34-
# TODO: mshick/add-pr-comment@v1 and alike won't work as well
35-
#- name: Update the PR
36-
# run: python3 ./ctf/utility_scripts/comment_pr.py --token ${{ github.token }} --pr ${{ github.event.pull_request.number }} --comment ctf.md
34+
- name: Detect content changes in the PR
35+
run: python3 ./ctf/content_test_filtering.py pr --base ${{ steps.fork_point.outputs.FORK_POINT }} --remote_repo ${{ github.server_url }}/${{ github.repository }} --verbose --rule --output json ${{ github.event.pull_request.number }} > output.json
36+
- name: Test if there are no content changes
37+
run: echo "::set-output name=CTF_OUTPUT_SIZE::$(stat --printf="%s" output.json)"
38+
id: ctf
39+
- name: Print changes to content detected if any
40+
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
41+
run: cat output.json
42+
- name: Get product attribute
43+
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
44+
id: product
45+
uses: notiz-dev/github-action-json-property@release
46+
with:
47+
path: 'output.json'
48+
prop_path: 'product'
49+
- name: Find Comment
50+
uses: peter-evans/find-comment@v1
51+
id: fc
52+
with:
53+
issue-number: ${{ github.event.pull_request.number }}
54+
comment-author: 'github-actions[bot]'
55+
body-includes: This datastream diff is auto generated by the check
56+
- name: Create or update comment
57+
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE != '0' }}
58+
uses: peter-evans/create-or-update-comment@v1
59+
with:
60+
comment-id: ${{ steps.fc.outputs.comment-id }}
61+
issue-number: ${{ github.event.pull_request.number }}
62+
body: |
63+
Start a new ephemeral environment with changes proposed in this pull request
64+
65+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#PRODUCT=${{steps.product.outputs.prop}}/${{ github.server_url }}/${{ github.repository }}/pulls/${{ github.event.pull_request.number }})
66+
67+
edit-mode: replace
68+
- name: Create or update a trimmed comment
69+
if: ${{ steps.ctf.outputs.CTF_OUTPUT_SIZE == '0' }}
70+
uses: peter-evans/create-or-update-comment@v1
71+
with:
72+
comment-id: ${{ steps.fc.outputs.comment-id }}
73+
issue-number: ${{ github.event.pull_request.number }}
74+
body: |
75+
Start a new ephemeral environment with changes proposed in this pull request
76+
77+
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#${{ github.server_url }}/${{ github.repository }}/pulls/${{ github.event.pull_request.number }})
78+
79+
edit-mode: replace

.github/workflows/ssgts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: echo "::set-output name=FORK_POINT::$(git merge-base origin/$BASE_BRANCH ${{ github.event.pull_request.head.sha }})"
2929
id: fork_point
3030
- name: Detect content changes in the PR
31-
run: python3 ./ctf/content_test_filtering.py pr --base ${{ steps.fork_point.outputs.FORK_POINT }} --verbose --rule --output json ${{ github.event.pull_request.number }} > output.json
31+
run: python3 ./ctf/content_test_filtering.py pr --base ${{ steps.fork_point.outputs.FORK_POINT }} --remote_repo ${{ github.server_url }}/${{ github.repository }} --verbose --rule --output json ${{ github.event.pull_request.number }} > output.json
3232
- name: Test if there are no content changes
3333
run: echo "::set-output name=CTF_OUTPUT_SIZE::$(stat --printf="%s" output.json)"
3434
id: ctf

0 commit comments

Comments
 (0)