-
Notifications
You must be signed in to change notification settings - Fork 0
200 lines (170 loc) · 5.82 KB
/
test.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Tests
on:
push:
branches: [ 'newforms', 'composite_level', 'main' ]
pull_request_target:
jobs:
build_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- id: set-matrix
run: |
matrix=$((
# echo '{ "os" : ["ubuntu-latest", "macos-latest"],'
echo '{ "os" : ["ubuntu-latest"],'
echo '"target" : ['
ls -1 Tests | sed -r 's/^([^,]*)(,?)$/"\1"\2/' | paste -sd "," -
echo " ],"
echo '"include" : [{"pkg_man": "sudo apt-get", "os": "ubuntu-latest"},'
# echo '{"pkg_man" : "brew", "os": "macos-latest"},'
echo '{"ip_cmd" : "sudo ip link add dumdum type dummy && sudo ifconfig dumdum ", "os": "ubuntu-latest"},'
# echo '{"ip_cmd" : "sudo ifconfig lo0 ", "os" : "macos-latest"},'
echo '{"magma_url" : "MAGMA_URL", "os": "ubuntu-latest"},'
# echo '{"magma_url" : "MAGMA_URL_MACOS", "os" : "macos-latest"},'
# echo '{"add_pkgs": "mpfr gmp pari iproute2mac || brew link --overwrite python@3.11", "os": "macos-latest" },'
echo '{"add_pkgs": "libgmp-dev libmpfr-dev libtool-bin libpari-dev", "os": "ubuntu-latest"}'
echo ' ]}'
) | jq -c .)
echo $matrix
echo $matrix | jq .
echo "matrix=$matrix" >> $GITHUB_OUTPUT
check-matrix:
runs-on: ubuntu-latest
needs: build_matrix
steps:
- name: Install json2yaml
run: |
sudo npm install -g json2yaml
- name: Check matrix definition
run: |
matrix='${{needs.build_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
has_access_macos:
runs-on: macos-latest
outputs:
has_access_macos: ${{ steps.my-key.outputs.has_access_macos }}
steps:
- id: my-key
env:
MAGMA_URL_MACOS: ${{ secrets.MAGMA_URL_MACOS }}
if: "${{ env.MAGMA_URL_MACOS != '' }}"
run: |
echo "has_access_macos=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}}
check-has_access_macos:
runs-on: macos-latest
needs: has_access_macos
steps:
- name: Check has_access_macos definition
run: |
echo ${{needs.has_access_macos.outputs.has_access_macos}}
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: ${{ matrix.os }}
name: Run tests
needs: [has_access, has_access_macos, build_matrix]
if: (needs.has_access.outputs.has_access == 'true') && (needs.has_access_macos.outputs.has_access_macos == 'true')
strategy:
fail-fast: false
matrix: ${{fromJson(needs.build_matrix.outputs.matrix)}}
steps:
- name: Check user permission
id: check
uses: assaferan/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@v3
if: ${{ github.event_name == 'push' }}
- name: Checkout for a PR event
uses: actions/checkout@v3
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 }} ${{ matrix.os }}
- name: Install magma
env:
MAGMA_URL: ${{ secrets.MAGMA_URL }}
MAGMA_URL_MACOS: ${{ secrets.MAGMA_URL_MACOS }}
shell: bash
if: steps.magmacache.outputs.cache-hit != 'true'
run: |
wget "$${{ matrix.magma_url }}" -O magma.tar.gz --quiet
tar xf magma.tar.gz
- name: Install dependencies
run: |
${{ matrix.pkg_man }} update
${{ matrix.pkg_man }} install autoconf automake libtool ${{ matrix.add_pkgs }}
- name: Check magma pass file
run: |
export MAGMAPASSFILE="./magma/magmapassfile"
chmod +r ./magma/magmapassfile
ls -l ./magma/magmapassfile
echo $MAGMAPASSFILE
- name: Create dummy network device
shell: bash
run: |
${{ matrix.ip_cmd }} hw ether `./magma/magma -d | grep "Valid MAC addresses" -A1 | tail -n1`
echo | ./magma/magma
- name: Build
run: |
./autogen.sh
./configure
make
- name: Run tests
shell: bash
run: |
mkdir -p data
./magma/magma -b target:=${{matrix.target}} exitsignal:="" run_tests.m