-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (88 loc) · 3.07 KB
/
build.yaml
File metadata and controls
104 lines (88 loc) · 3.07 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
---
name: Build and Test
permissions:
contents: read
on:
push:
branches:
- main
pull_request:
merge_group:
env:
CARGO_TERM_COLOR: always
RUST_TOOLCHAIN_VERSION: "1.93.0"
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust ${{ env.RUST_TOOLCHAIN_VERSION }} toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
components: clippy
- name: Setup Rust Cache
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
- name: Build
run: cargo build --release
- name: Run unit tests
run: cargo test --lib --bins
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
static-binary:
name: Static (musl) Build
runs-on: ubuntu-latest
needs: [unit-tests]
steps:
- name: Install host dependencies
uses: awalsh128/cache-apt-pkgs-action@acb598e5ddbc6f68a970c5da0688d2f3a9f04d05 # v1.6.0
with:
packages: musl-tools
version: ubuntu-latest
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Rust ${{ env.RUST_TOOLCHAIN_VERSION }} toolchain
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
with:
toolchain: ${{ env.RUST_TOOLCHAIN_VERSION }}
targets: x86_64-unknown-linux-musl
- name: Setup Rust Cache
uses: Swatinem/rust-cache@23869a5bd66c73db3c0ac40331f3206eb23791dc # v2.9.1
with:
key: musl
- name: Build static binary
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Confirm binary is statically linked
run: |
file target/x86_64-unknown-linux-musl/release/postgresql-trino-gateway \
| tee /tmp/file.out
# `file` reports a fully-static musl binary as either
# "statically linked" (older builds) or "static-pie linked"
# (newer Rust + musl default — position-independent AND
# statically linked). Both are fine; reject only "dynamically
# linked".
grep -qE 'statically linked|static-pie linked' /tmp/file.out
! grep -q 'dynamically linked' /tmp/file.out
# Single required check for branch protection rules.
finished:
name: Finished Build and Test
if: always()
needs:
- unit-tests
- static-binary
runs-on: ubuntu-latest
steps:
- name: Check job results
run: |
if [[ "${{ needs.unit-tests.result }}" != "success" ]] ||
[[ "${{ needs.static-binary.result }}" != "success" ]]; then
echo "One or more jobs failed"
exit 1
fi
echo "All jobs passed"