-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (92 loc) · 3.76 KB
/
compile-dependency.yml
File metadata and controls
106 lines (92 loc) · 3.76 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
name: 'Compile Dependency on Target - Reusable Workflow'
description: |
Compiles Dependency on given target, os, and arch
on:
workflow_call:
inputs:
version:
description: 'dependency version'
required: true
type: string
target:
description: 'dependency OS target variant'
required: true
type: string
os:
description: 'platform OS (e.g., linux)'
required: true
type: string
arch:
description: 'platform architecture (e.g., amd64)'
required: true
type: string
shouldCompile:
description: 'whether to compile the dependency'
required: true
type: boolean
shouldTest:
description: 'whether to test the dependency after compilation'
required: true
type: boolean
uploadArtifactName:
description: 'name of the artifact to upload'
required: true
type: string
jobs:
compile:
# Speed up compilation by using runners that match os and arch when they are set, otherwise fall back to emulation.
runs-on: ${{ (inputs.os == 'linux' && inputs.arch == 'arm64') && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
steps:
- name: Check out code
uses: actions/checkout@v6
- name: Enable experimental features for Docker daemon and CLI
run: |
echo '{"experimental": true}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
mkdir -p ~/.docker
echo '{"experimental": "enabled"}' | sudo tee ~/.docker/config.json
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Setup before compilation
id: compile-setup
run: |
echo "outputdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
- name: docker build
id: docker-build
env:
SKIP_LOGIN: true
if: ${{ inputs.shouldCompile == true || inputs.shouldCompile == 'true' }}
uses: actions-hub/docker/cli@master
with:
args: "build ${{ (inputs.os != '' && inputs.arch != '') && format('--platform {0}/{1}', inputs.os, inputs.arch) || '' }} -t compilation -f dependency/actions/compile/${{ inputs.target }}.Dockerfile dependency/actions/compile"
- name: docker run
id: docker-run
uses: actions-hub/docker/cli@master
env:
SKIP_LOGIN: true
if: ${{ inputs.shouldCompile == true || inputs.shouldCompile == 'true' }}
with:
args: "run ${{ (inputs.os != '' && inputs.arch != '') && format('--platform {0}/{1}', inputs.os, inputs.arch) || '' }} -v ${{ steps.compile-setup.outputs.outputdir }}:/home compilation --outputDir /home --target ${{ inputs.target }} --version ${{ inputs.version }} ${{ inputs.os != '' && format('--os {0}', inputs.os) || '' }} ${{ inputs.arch != '' && format('--arch {0}', inputs.arch) || '' }}"
- name: Print contents of output dir
shell: bash
run: ls -lah ${{ steps.compile-setup.outputs.outputdir }}
- name: Test Dependency
working-directory: dependency
if: ${{ (inputs.shouldCompile == true || inputs.shouldCompile == 'true') && (inputs.shouldTest == true || inputs.shouldTest == 'true') }}
run: |
#!/usr/bin/env bash
set -euo pipefail
shopt -s inherit_errexit
make test \
version="${{ inputs.version }}" \
tarballPath="${{ steps.compile-setup.outputs.outputdir }}/*.tgz" \
os="${{ inputs.os }}" \
arch="${{ inputs.arch }}"
- name: Upload compiled artifact
uses: actions/upload-artifact@v6
if: ${{ inputs.shouldCompile == true || inputs.shouldCompile == 'true' }}
with:
name: '${{ inputs.uploadArtifactName }}'
path: '${{ steps.compile-setup.outputs.outputdir }}/*'