Skip to content

Commit ff8b7ba

Browse files
authored
Merge pull request #8 from K4ddate/workflows
feat: decouple workflows and add PR trigger
2 parents 83aa737 + 6877133 commit ff8b7ba

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

.github/workflows/generate-go-constants.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This workflow generates source code that will be committed to the repository.
2+
# It should NEVER be triggered by untrusted sources.
13
name: Generate golang constants
24

35
on:

.github/workflows/run-unit-tests.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
name: Run unit tests
22

33
on:
4-
workflow_run:
5-
workflows:
6-
- "Generate golang constants"
7-
branches:
8-
- main
9-
types:
10-
- completed # ensure the generation of constants is finished before running tests
4+
push:
5+
branches: [main]
6+
pull_request:
117
workflow_dispatch:
128
inputs:
139
unicorn_ref:
@@ -34,6 +30,10 @@ jobs:
3430
with:
3531
go-version: stable
3632

33+
- name: Install stringer tool
34+
run: |
35+
go install golang.org/x/tools/cmd/stringer@latest
36+
3737
- name: Resolve unicorn ref
3838
id: resolve
3939
env:
@@ -42,27 +42,39 @@ jobs:
4242
OVERRIDE="${{ github.event.inputs.unicorn_ref }}"
4343
if [ -n "$OVERRIDE" ]; then
4444
echo "ref=$OVERRIDE" >> $GITHUB_OUTPUT
45-
4645
elif [ "${{ matrix.unicorn_ref }}" = "latest_tag" ]; then
4746
TAG=$(curl -sf https://api.github.com/repos/unicorn-engine/unicorn/releases/latest | jq -r '.tag_name')
4847
echo "ref=$TAG" >> $GITHUB_OUTPUT
49-
5048
else
5149
echo "ref=dev" >> $GITHUB_OUTPUT
5250
fi
5351
54-
- name: Clone unicorn
52+
- name: Clone unicorn-engine
5553
run: |
5654
git clone \
5755
--depth 1 \
5856
--branch ${{ steps.resolve.outputs.ref }} \
5957
https://github.com/unicorn-engine/unicorn \
60-
unicorn
58+
build/unicorn
59+
60+
- name: Generate files
61+
run: |
62+
cd build
63+
python3 ./const_generator.py -i ./unicorn/include/unicorn -o ..
64+
65+
- name: Generate Go related files
66+
run: |
67+
stringer -linecomment -type GoUcError -output ./unicorn_go_const_stringers.go ./unicorn_go_const.go
68+
69+
- name: Format go files
70+
run: |
71+
go fmt .
6172
6273
- name: Build & install unicorn
6374
run: |
64-
cd unicorn
65-
mkdir build && cd build
75+
cd build/unicorn
76+
mkdir build
77+
cd build
6678
cmake .. -DCMAKE_BUILD_TYPE=Release
6779
make -j$(nproc)
6880
sudo make install

0 commit comments

Comments
 (0)