-
-
Notifications
You must be signed in to change notification settings - Fork 66
145 lines (121 loc) · 4.03 KB
/
tangle.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
name: Tangle code extracted from documentation
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
# Allow one concurrent test
concurrency:
group: "tangle"
cancel-in-progress: true
env:
BUILD_TYPE: Release
jobs:
# Tangle job
tangle:
runs-on: ubuntu-latest
outputs:
tangle-roots: ${{ steps.set-tangle-roots.outputs.roots }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: Setup Python
run: pip install -r requirements.txt
- name: Build with Sphinx
run: make tangle
- name: List tangle roots
id: set-tangle-roots
run: echo "roots=$(printf '['; find _build/tangle -maxdepth 1 -mindepth 1 -type d -printf '"%P", '; printf ']\n')" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: tangled-code
path: _build/tangle
# Filter unnecessary tests
filter-unchanged:
runs-on: ubuntu-latest
needs: tangle
outputs:
tangle-roots: ${{ steps.filter-tangle-roots.outputs.roots }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download current tangle
uses: actions/download-artifact@v3
with:
name: tangled-code
path: current
- name: Download previous tangle
id: download-previous-tangle
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_ID: ${{ github.run_id }}
REPO: ${{ github.repository }}
BRANCH: ${{ github.branch }}
run: |
# FTR: API_HEADERS="-H 'Accept: application/vnd.github+json' -H 'X-GitHub-Api-Version: 2022-11-28'"
API_PREFIX=repos/$REPO/actions
# Get Workflow ID from Run ID
WORKFLOW_ID=$(gh api $API_PREFIX/runs/$RUN_ID -q .workflow_id)
echo WORKFLOW_ID=$WORKFLOW_ID
# Get previous Run ID from Workflow ID
PREV_RUN_ID=$(gh api "$API_PREFIX/workflows/$WORKFLOW_ID/runs?status=success&per_page=1&branch=$BRANCH" -q '.workflow_runs[0] | .id')
echo PREV_RUN_ID=$PREV_RUN_ID
# Download previous artifact
gh run download $PREV_RUN_ID -R $REPO -n tangled-code -D previous
- name: Filter out unchanged roots
if: failure() || success()
id: filter-tangle-roots
env:
roots: ${{ needs.tangle.outputs.tangle-roots }}
downloadPreviousOutcome: ${{ steps.download-previous-tangle.outcome }}
run: |-
if [[ $downloadPreviousOutcome -eq "success" ]]
then
# Only keep the ones that changed
echo "roots=$(python tools/filter_unchanged_tangle_roots.py "$roots" current previous)" >> $GITHUB_OUTPUT
else
# Just forward the list
echo "roots=$roots" >> $GITHUB_OUTPUT
fi
# Test job
test:
if: ${{ needs.filter-unchanged.outputs.tangle-roots != '[]' }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
tangle-root: ${{ fromJson(needs.filter-unchanged.outputs.tangle-roots) }}
include:
- os: ubuntu-latest
install-deps: |
sudo apt-get update -y
sudo apt-get install -y xorg-dev
runs-on: ${{ matrix.os }}
needs: [tangle, filter-unchanged]
steps:
- if: ${{ matrix.install-deps }}
name: Install dependencies
run: ${{ matrix.install-deps }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: tangled-code
- name: Configure CMake
run: >
cmake
-S "${{ matrix.tangle-root }}"
-B ${{github.workspace}}/build
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
-DGLFW_BUILD_WAYLAND=OFF
- name: Build
run: >
cmake
--build ${{github.workspace}}/build
--config ${{env.BUILD_TYPE}}