-
Notifications
You must be signed in to change notification settings - Fork 8
145 lines (128 loc) · 5.32 KB
/
pull-request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#
# This workflow is run for pull requests the modify the `packages` directory.
# It works in two stages: first it determines the list of added, modified or
# removed packages; for each added or modified package, it executes the
# `validate_package.py` script to check for issues with the metadata or
# tarball. Provided these initial tests pass, the second stage consists of
# invoking a separate workflow which runs tests for all packages in the
# package distribution as they would appear when the PR under review would be
# merged. This is used to determine whether any package tests change from PASS
# to FAIl or vice versa.
#
name: "PR"
on:
workflow_dispatch: # manual trigger for debugging
pull_request:
paths:
- 'packages/*/meta.json'
concurrency:
# group by workflow and ref
group: ${{ github.workflow }}-${{ github.ref }}
# Cancel intermediate builds, but only if it is a pull request build.
cancel-in-progress: true
jobs:
detect-changes:
name: "Detect affected packages"
runs-on: ubuntu-20.04
if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip tests') }}
outputs:
modified: ${{ steps.modified.outputs.modified }}
steps:
# clone with depth 0, so that we can determine what was changed
# TODO: isn't depth 1 sufficient?
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Install package distribution tools"
run: python -m pip install -r tools/requirements.txt
# the following step is useful for debugging
- name: "Determine system architecture for -march=native"
run: |
echo "cc -march=native: $(tools/compiler_arch.sh cc)"
echo "c++ -march=native: $(tools/compiler_arch.sh c++)"
# Setup ccache, to speed up repeated compilation of the same binaries
# (i.e., GAP and the packages)
- name: "Setup ccache"
uses: Chocobo1/setup-ccache-action@v1
with:
update_packager_index: false
- name: "Install GAP"
uses: gap-actions/setup-gap@v2
with:
GAP_BOOTSTRAP: 'minimal'
GAP_PKGS_TO_CLONE: 'json'
GAP_PKGS_TO_BUILD: 'json'
- name: "Determine what was added or modified, validate"
id: modified
run: |
modified=$(git diff --name-only --no-renames --diff-filter=AM ${{ github.event.pull_request.base.sha }} -- packages/*/meta.json)
echo "Added or updated packages: ${modified}"
if [[ -n "${modified}" ]]; then
echo "modified=true" >> $GITHUB_OUTPUT
else
echo "modified=false" >> $GITHUB_OUTPUT
fi
echo "Obtain copies of old metadata, if any..."
for PKG in ${modified}; do
git cat-file blob ${{ github.event.pull_request.base.sha }}:$PKG > $PKG.old || rm -f $PKG.old
done
echo "Validate metadata..."
tools/validate_package.py ${modified}
test-all-master:
name: "master"
needs: detect-changes
if: ${{ needs.detect-changes.outputs.modified == 'true' }}
uses: ./.github/workflows/test-all.yml
with:
which-gap: 'master'
test-all-release:
name: "4.12.1"
needs: detect-changes
if: ${{ needs.detect-changes.outputs.modified == 'true' }}
uses: ./.github/workflows/test-all.yml
with:
which-gap: '4.12.1'
status-comment:
name: "Create or update PR comment"
runs-on: ubuntu-20.04
needs: test-all-master # TODO: also handle test-all-release
if: always()
steps:
- name: "Download report"
uses: actions/download-artifact@v3
with:
name: report-master
path: _report
- name: "Prepare report.md"
id: get-comment-body
run: |
echo "body<<EOF1234567890EOF" >> $GITHUB_OUTPUT
cat _report/report.md >> $GITHUB_OUTPUT
echo "EOF1234567890EOF" >> $GITHUB_OUTPUT
- name: "Find Comment"
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
# comment-author: "gap-package-distribution-bot <100730870+gap-package-distribution-bot[bot]@users.noreply.github.com>"
body-includes: "Package Evaluation Report"
# We set up a GitHub App in order to ensure that workflows are run on the PRs
# created by us, following the instructions here:
# <https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens>
# The bot can also be set up for personal forks of this repository, for testing
# and debugging, see <https://github.com/apps/gap-package-distribution-bot>.
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# TODO: extra work is needed to make the following work with pull requests
# that come from forks of this repository.
- name: "Create or update comment"
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ steps.generate-token.outputs.token }}
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.get-comment-body.outputs.body }}
edit-mode: replace