This repository has been archived by the owner on Aug 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
65 lines (65 loc) · 2.51 KB
/
generate-test-vectors.yaml
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
name: Generate Test Vectors
on:
push:
branches:
- master
paths-ignore:
- corpus/**/*.json
jobs:
update-vectors:
name: Update test vectors
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3.5.3
with:
submodules: true
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install ocl-icd-opencl-dev
- name: Build filecoin-ffi
run: cd gen/extern/filecoin-ffi && make
- name: Update test vectors
run: make upgen
- name: Generate vars
id: vars
run: |
echo ::set-output name=sha_short::$(git rev-parse --short=7 ${{ github.sha }})
echo ::set-output name=branch::chore/update-test-vectors-$(git rev-parse --short=7 ${{ github.sha }})
if [ -n "$(git status -s -- corpus/**/*.json)" ]; then
echo ::set-output name=changes_detected::true
fi
- name: Commit and push
if: steps.vars.outputs.changes_detected
env:
COMMIT_MESSAGE: "Update test vectors"
run: |
git checkout -b ${{ steps.vars.outputs.branch }}
git add corpus/**/*.json
git -c user.name="GitHub Actions" -c user.email="actions@github.com" commit -m "$COMMIT_MESSAGE" --author="${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
git push origin ${{ steps.vars.outputs.branch }}
- name: Open PR
if: steps.vars.outputs.changes_detected
env:
PR_TITLE: "Update test vectors (${{ steps.vars.outputs.sha_short }})"
PR_BODY: "This PR updates the test vectors that were changed in the commit ${{ github.sha }}."
run: |
STATUS_CODE=$(curl -o .output -s -w "%{http_code}\n" \
--data "{\"title\":\"$PR_TITLE\", \"body\":\"$PR_BODY\", \"head\": \"${{ steps.vars.outputs.branch }}\", \"base\": \"master\"}" \
-X POST \
-H "Authorization: token ${{ github.token }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls")
if [ $STATUS_CODE -ne 201 ]; then
echo "Error: unexpected status $STATUS_CODE\nResponse:"
cat .output
exit 1
fi