forked from ruslo/hunter
-
Notifications
You must be signed in to change notification settings - Fork 191
186 lines (156 loc) · 5.35 KB
/
ci.yml
File metadata and controls
186 lines (156 loc) · 5.35 KB
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
name: CI
on:
push:
paths:
- 'cmake/projects/**'
- 'cmake/modules/**'
- 'cmake/schemes/**'
- 'cmake/templates/**'
- 'tests/**'
pull_request:
paths:
- 'cmake/projects/**'
- 'cmake/modules/**'
- 'cmake/schemes/**'
- 'cmake/templates/**'
- 'tests/**'
workflow_dispatch:
inputs:
project:
description: 'Project name'
required: true
jobs:
check_urls:
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4.1.1
- name: Manual dispatch, get project name from input
if: github.event_name == 'workflow_dispatch'
run: |
echo '["cmake/projects/${{ github.event.inputs.project }}/hunter.cmake"]' > ${HOME}/files.json
- name: Get changed files and save them to ${HOME}/files.json
if: github.event_name != 'workflow_dispatch'
id: files
uses: lots0logs/gh-action-get-changed-files@2.2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
sudo apt-get install -yq python3-pycurl
- name: Check changed projects for working URLs
run: |
python maintenance/check-urls.py
set_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Git checkout
uses: actions/checkout@v4.1.1
- name: Manual dispatch, get project name from input
if: github.event_name == 'workflow_dispatch'
run: |
echo '["cmake/projects/${{ github.event.inputs.project }}/hunter.cmake"]' > ${HOME}/files.json
- name: Get changed files and save them to ${HOME}/files.json
if: github.event_name != 'workflow_dispatch'
id: files
uses: lots0logs/gh-action-get-changed-files@2.2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set matrix for subsequent build
id: set-matrix
run: |
MATRIX=`python .github/workflows/set_matrix.py`
if [ "${MATRIX}" ]; then
echo "matrix=${MATRIX}" >> $GITHUB_OUTPUT
else
echo "matrix=${MATRIX}"
exit 1
fi
- uses: actions/upload-artifact@v4
with:
name: toolchains
path: .github/toolchains
build:
name: ${{ matrix.project }} ${{ matrix.toolchain }} ${{ matrix.os }}
needs: set_matrix
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.set_matrix.outputs.matrix) }}
env:
TOOLCHAIN: '${{ matrix.toolchain }}'
PROJECT_DIR: ${{ matrix.example }}
SCRIPT: ${{ matrix.script }}
GITHUB_USER_PASSWORD: ${{ secrets.CPP_PM_BOT_TOKEN }}
steps:
- name: Git checkout with submodules
uses: actions/checkout@v4.1.1
with:
submodules: true
- name: Download all workflow run artifacts
uses: actions/download-artifact@v4
- name: Set up Python
uses: actions/setup-python@v5.1.0
with:
python-version: ${{ matrix.python }}
- name: Set up Python environment variable (Unix)
if: runner.os != 'Windows'
run: echo "HUNTER_PYTHON_LOCATION=$pythonLocation" >> $GITHUB_ENV
- name: Set up Python environment variable (Windows)
if: runner.os == 'Windows'
run: echo "HUNTER_PYTHON_LOCATION=$env:pythonLocation" | Out-File -Append -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Install requests python module for upload script
run: python -m pip install requests gitpython
- name: Build on Unix
if: runner.os != 'Windows'
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
python .github/workflows/ci/build.py
- name: Build on Windows
if: runner.os == 'Windows' && matrix.toolchain != 'hunter_tests'
env:
BRANCH_NAME: ${{ github.ref_name }}
VCVARSALL: ${{ matrix.VCVARSALL }}
VCVARSALL_ARGS: ${{ matrix.VCVARSALL_ARGS }}
run: |
if ("$env:VCVARSALL") {
Write-Host "call VCVARSALL using command '${env:VCVARSALL}' and args '${env:VCVARSALL_ARGS}'"
cmd /c 'call "%VCVARSALL%" %VCVARSALL_ARGS% && set' | foreach {
if ($_ -match "=") {
#"processing line: '$_'"
$v = $_.split("=");
set-item -force -path "ENV:\$($v[0])" -value "$($v[1])";
}
}
}
python .github/workflows/ci/build.py
set_status:
needs: [ set_matrix, build ]
if: always() && needs.set_matrix.result == 'success' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4.1.1
- name: Get job status via GitHub API
uses: octokit/request-action@v2.x
id: get_job_data
with:
route: GET /repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Parse job status
run: |
mkdir job_data
echo '${{ steps.get_job_data.outputs.data }}' > job_data.json
python .github/workflows/set_status.py
- name: Deploy job status to GitHub Pages
uses: peaceiris/actions-gh-pages@v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: job_data
destination_dir: _data/projects
keep_files: true
enable_jekyll: true