forked from edgarcosta/hilbertmodularforms
-
Notifications
You must be signed in to change notification settings - Fork 0
158 lines (130 loc) · 3.89 KB
/
tests.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
146
147
148
149
150
151
152
153
154
155
156
157
name: Tests
on:
push:
branches: [ '**' ]
pull_request_target:
jobs:
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
if: ${{ github.event_name == 'push' }}
- uses: actions/checkout@v2
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- id: set-matrix
run: |
matrix=$((
echo '{ "target" : ['
ls -1 Tests | grep -v '^_' | sed -r 's/^([^,]*)(,?)$/"\1"\2/' | paste -sd "," -
echo " ]}"
) | jq -c .)
echo $matrix
echo $matrix | jq .
echo "matrix=$matrix" >> $GITHUB_OUTPUT
check-matrix:
runs-on: ubuntu-latest
needs: matrix
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{needs.matrix.outputs.matrix}}'
echo $matrix
echo $matrix | jq .
echo $matrix | json2yaml
has_access:
runs-on: ubuntu-latest
outputs:
has_access: ${{ steps.my-key.outputs.has_access }}
steps:
- id: my-key
env:
MAGMA_URL: ${{ secrets.MAGMA_URL }}
if: "${{ env.MAGMA_URL != '' }}"
run: |
echo "has_access=true" >> $GITHUB_OUTPUT
check-has_access:
runs-on: ubuntu-latest
needs: has_access
steps:
- name: Check has_access definition
run: |
echo ${{needs.has_access.outputs.has_access}}
printjob:
name: print event
runs-on: ubuntu-latest
if: false
steps:
- name: dump github context
env:
github_context: ${{ tojson(github) }}
run: |
echo "$github_context"
test:
runs-on: ubuntu-latest
name: Run tests
needs: [has_access, matrix]
if: needs.has_access.outputs.has_access == 'true'
strategy:
fail-fast: false
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- name: Check user permission
id: check
uses: scherermichael-oss/action-has-permission@master
with:
required-permission: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Stop workflow for users with no write access
if: "! steps.check.outputs.has-permission"
run: |
echo "Sorry! Your permissions are insufficient."
false
- name: The user has write access
if: "steps.check.outputs.has-permission"
run: |
echo "The user has write access"
- name: Checkout for a push event
uses: actions/checkout@v2
if: ${{ github.event_name == 'push' }}
- name: Checkout for a PR event
uses: actions/checkout@v2
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Cache magma
uses: actions/cache@v3
id: magmacache
env:
# Increase this value to reset cache when MAGMA_URL changes
CACHE_NUMBER: 2.27-6
with:
path: |
./magma
key:
${{ env.CACHE_NUMBER }}
- name: Install magma
env:
MAGMA_URL: ${{ secrets.MAGMA_URL }}
shell: bash
if: steps.magmacache.outputs.cache-hit != 'true'
run: |
wget "$MAGMA_URL" -O magma.tar.gz --quiet
tar xf magma.tar.gz
- name: Create dummy network device
shell: bash
run: |
sudo ip link add dumdum type dummy
sudo ifconfig dumdum hw ether `./magma/magma -d | grep "Valid MAC addresses" -A1 | tail -n1`
echo | ./magma/magma
- name: Run tests
shell: bash
run: |
./magma/magma -b target:=${{matrix.target}} exitsignal:="" run_tests.m