forked from ruslo/hunter
-
Notifications
You must be signed in to change notification settings - Fork 181
142 lines (119 loc) · 3.85 KB
/
ci.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
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:
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
exit 1
fi
build:
name: ${{ matrix.example }} ${{ 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: examples/${{ matrix.example }}
GITHUB_USER_PASSWORD: ${{ secrets.CPP_PM_BOT_TOKEN }}
steps:
- name: Git checkout with submodules
uses: actions/checkout@v4.1.1
with:
submodules: true
- 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: Build hunter_tests Unix
if: runner.os != 'Windows' && matrix.toolchain == 'hunter_tests'
env:
PROJECT_DIR: ${{ matrix.example }}
run: |
bash ${{ matrix.script }}
- name: Build on Unix
if: runner.os != 'Windows' && matrix.toolchain != 'hunter_tests'
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
bash ${{ matrix.script }}
- name: Build on Windows
if: runner.os == 'Windows' && matrix.toolchain != 'hunter_tests'
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
${{ matrix.script }}
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