-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
102 lines (94 loc) · 3.09 KB
/
action.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
name: 'CI'
description: 'Clone the user of the dependency, change its build.zig.zon and apply some tests'
inputs:
repository:
description: 'Current repository'
required: true
additional_zig_opts:
description: 'Additional Zig options'
required: false
sha:
description: 'Current commit sha'
required: true
user:
description: 'User of the dependency'
required: true
token:
description: 'The github token'
required: true
test_build:
description: 'Do we test `zig build` command ?'
required: true
test_update:
description: 'Do we test `zig build -Dupdate` command ?'
required: true
test_fetch:
description: 'Do we test `zig build -Dfetch` command ?'
required: true
runs:
using: "composite"
steps:
- uses: tiawl/[email protected]
- name: Setup Zig
uses: mlugg/setup-zig@v1
with:
version: ${{ env.zig_version }}
- name: Install packages
if: runner.os == 'LINUX'
env:
PACKAGES: "${{ env.apt_packages }}"
shell: ${{ env.shell }}
run: |
sudo apt-get install -y ${PACKAGES}
printf 'ACTIVATE_DIR=bin\n' >> "${GITHUB_ENV}"
- uses: actions/checkout@v4
with:
repository: "${{ github.repository_owner }}/${{ inputs.user }}"
- name: Activate python virtual env & install pip packages
env:
PACKAGES: "${{ env.pip_packages }}"
RUNNER_TMP: "${{ runner.temp }}"
shell: ${{ env.shell }}
run: |
python3 -m venv "${RUNNER_TMP}/venv"
source "${RUNNER_TMP}/venv/${ACTIVATE_DIR:-Scripts}/activate"
pip install ${PACKAGES}
- name: Prepare ${{ inputs.user }}/build.zig.zon
env:
SHA: "${{ inputs.sha }}"
URL: "${{ github.server_url }}/${{ inputs.repository }}/archive"
shell: ${{ env.shell }}
run: |
old_url="$(grep -o "${URL}/.*\.tar\.gz" build.zig.zon)"
old_hash="$(zig fetch "${old_url}")"
new_url="${URL}/${SHA}.tar.gz"
new_hash="$(zig fetch "${new_url}")"
sed -i "s@${old_url}@${new_url}@;
s@${old_hash}@${new_hash}@" build.zig.zon
- name: Test building ${{ inputs.user }}
if: inputs.test_build == 'true'
env:
OPTIONS: "${{ inputs.additional_zig_opts }}"
RUNNER_TMP: "${{ runner.temp }}"
shell: ${{ env.shell }}
run:
source "${RUNNER_TMP}/venv/${ACTIVATE_DIR:-Scripts}/activate"
zig build ${OPTIONS}
- name: Test updating ${{ inputs.user }}
if: inputs.test_update == 'true'
env:
OPTIONS: "${{ inputs.additional_zig_opts }}"
RUNNER_TMP: "${{ runner.temp }}"
shell: ${{ env.shell }}
run:
source "${RUNNER_TMP}/venv/${ACTIVATE_DIR:-Scripts}/activate"
zig build -Dupdate ${OPTIONS}
- name: Test fetching ${{ inputs.user }}
if: inputs.test_fetch == 'true'
env:
OPTIONS: "${{ inputs.additional_zig_opts }}"
RUNNER_TMP: "${{ runner.temp }}"
shell: ${{ env.shell }}
run:
source "${RUNNER_TMP}/venv/${ACTIVATE_DIR:-Scripts}/activate"
zig build -Dfetch ${OPTIONS}