Repository navigation
98 lines (87 loc) · 5.03 KB
/
Copy pathanalyzer-build.yml
File metadata and controls
98 lines (87 loc) · 5.03 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
name: analyzer-build
# Builds the reachability analyzer (analyzers/reach, Rust) on a runner of every platform the NuGet package bundles it for, so that
# (apart from the static musl one, ADR 0033) nothing is cross-compiled and every binary is smoke-tested on the platform it is for. Used by ci.yml (on every push and pull
# request, so a platform that stops building is found before a release) and by release.yml. ADR 0022.
on:
workflow_call:
inputs:
cache:
description: Reuse downloaded and compiled dependencies from earlier runs. ci.yml does; a release never does (it builds from scratch, ADR 0032)
type: boolean
default: false
permissions:
contents: read
jobs:
build:
name: analyzer (${{ matrix.rid }})
strategy:
fail-fast: false
matrix:
include:
- { rid: linux-x64, os: ubuntu-latest, exe: deprisk-reach, target-args: "", out: target/release }
- { rid: linux-musl-x64, os: ubuntu-latest, exe: deprisk-reach, target-args: "--target x86_64-unknown-linux-musl", out: target/x86_64-unknown-linux-musl/release }
- { rid: linux-arm64, os: ubuntu-24.04-arm, exe: deprisk-reach, target-args: "", out: target/release }
- { rid: osx-x64, os: macos-15-intel, exe: deprisk-reach, target-args: "", out: target/release }
- { rid: osx-arm64, os: macos-15, exe: deprisk-reach, target-args: "", out: target/release }
- { rid: win-x64, os: windows-latest, exe: deprisk-reach.exe, target-args: "", out: target/release }
- { rid: win-arm64, os: windows-11-arm, exe: deprisk-reach.exe, target-args: "", out: target/release }
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v5
- name: Rust toolchain (pinned by analyzers/reach/rust-toolchain.toml)
working-directory: analyzers/reach
run: |
rustup toolchain install
rustup show active-toolchain
# The musl analyzer is linked statically (the Rust musl target does that by default) and its C code (the grammars) is compiled with musl-gcc.
# It is built on a glibc runner, which makes this the one cross-compiled analyzer; the checks below run it in an Alpine container (ADR 0033).
- name: musl target and C compiler
if: matrix.rid == 'linux-musl-x64'
working-directory: analyzers/reach
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends musl-tools
rustup target add x86_64-unknown-linux-musl
- name: Cache dependencies and build output (never in a release)
if: inputs.cache
uses: actions/cache@v5
with:
path: |
~/.cargo/registry/index
~/.cargo/registry/cache
~/.cargo/git/db
analyzers/reach/target
key: cargo-${{ matrix.rid }}-${{ hashFiles('analyzers/reach/rust-toolchain.toml', 'analyzers/reach/Cargo.toml', 'analyzers/reach/Cargo.lock', 'analyzers/reach/src/**') }}
restore-keys: |
cargo-${{ matrix.rid }}-
- name: Build (locked dependencies, release profile)
working-directory: analyzers/reach
run: |
rustc --version
cargo build --release --locked ${{ matrix.target-args }}
# The binary must start on this platform and answer a request in the protocol (an empty target list is a valid request).
- name: Smoke test
run: |
echo '{"schemaVersion":1,"language":"javascript","root":".","targets":[]}' | analyzers/reach/${{ matrix.out }}/${{ matrix.exe }} | tee smoke.json
grep -q '"language":"javascript"' smoke.json
echo '{"schemaVersion":1,"language":"python","root":".","targets":[]}' | analyzers/reach/${{ matrix.out }}/${{ matrix.exe }} | grep -q '"language":"python"'
echo '{"schemaVersion":1,"language":"java","root":".","targets":[]}' | analyzers/reach/${{ matrix.out }}/${{ matrix.exe }} | grep -q '"language":"java"'
echo '{"schemaVersion":1,"root":".","targets":[]}' | analyzers/reach/${{ matrix.out }}/${{ matrix.exe }} | grep -q '"language":"csharp"'
# A static binary runs on a glibc runner too, so the smoke test above proves little for musl: this one runs it where it is for.
- name: musl checks (no dynamic loader; starts and answers on Alpine)
if: matrix.rid == 'linux-musl-x64'
run: |
bin="analyzers/reach/${{ matrix.out }}/${{ matrix.exe }}"
file "$bin"
if readelf -lW "$bin" | grep -q INTERP; then echo "the musl analyzer must be statically linked"; exit 1; fi
echo '{"schemaVersion":1,"language":"javascript","root":".","targets":[]}' | docker run --rm -i -v "$PWD/$(dirname "$bin"):/analyzer:ro" alpine:3.22 /analyzer/${{ matrix.exe }} | tee alpine.json
grep -q '"language":"javascript"' alpine.json
- uses: actions/upload-artifact@v7
with:
name: analyzer-${{ matrix.rid }}
path: analyzers/reach/${{ matrix.out }}/${{ matrix.exe }}
if-no-files-found: error
retention-days: 14