Repository navigation
102 lines (88 loc) · 3.81 KB
/
Copy pathlinux.yml
File metadata and controls
102 lines (88 loc) · 3.81 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
name: Linux
on:
push:
branches: [main, "v[0-9]+.[0-9]+.[0-9]+"]
pull_request:
branches: [main, "v[0-9]+.[0-9]+.[0-9]+"]
release:
types:
- created
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.7
- name: Install fmt, clippy and nightly for the fmt
run: |
rustup component add rustfmt
rustup component add clippy
rustup toolchain install nightly
rustup component add --toolchain nightly rustfmt
- name: Run fmt
run: cargo +nightly fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Build
run: cargo build --tests --verbose
- name: Run tests
run: cargo test --verbose
deploy:
needs: test
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
strategy:
matrix:
target: [i686-unknown-linux-gnu, x86_64-unknown-linux-gnu]
steps:
- uses: actions/checkout@v4.1.7
- id: "auth"
uses: google-github-actions/auth@v2.1.5
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: "Set up Cloud SDK"
uses: google-github-actions/setup-gcloud@v2.1.1
- name: Cache cargo registry and build artifacts
uses: actions/cache@v4
with:
path: |
~/.cargo-container/registry
~/.cargo-container/git
target
key: ${{ runner.os }}-release-cargo-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-release-cargo-${{ matrix.target }}-
# Build inside the official Rust image on Debian bullseye (glibc 2.31, the same floor
# as Ubuntu 20.04) so the binaries run on older systems and the toolchain ships in the
# image instead of being downloaded on every run. gcc/g++-multilib provide the 32-bit
# toolchain for the i686 target. tmc-langs builds BoringSSL (boring-sys), which needs
# libclang, cmake >= 3.22 (bullseye ships 3.18) and SSE2 on i686. The image tag pins the
# toolchain to the MSRV. Cargo caches are mounted in and ownership normalised afterwards
# so the cache and gsutil can read the root-owned tree.
- name: Cargo build
run: |
mkdir -p "$HOME/.cargo-container/registry" "$HOME/.cargo-container/git"
docker run --rm \
-v "$PWD":/w -w /w \
-v "$HOME/.cargo-container/registry":/usr/local/cargo/registry \
-v "$HOME/.cargo-container/git":/usr/local/cargo/git \
rust:1.88.0-bullseye bash -euo pipefail -c '
export DEBIAN_FRONTEND=noninteractive
# bullseye is past end of life and deb.debian.org no longer serves all of its packages
sed -i "s|http://deb.debian.org|http://archive.debian.org|g" /etc/apt/sources.list
apt-get update
apt-get install -y gcc-multilib g++-multilib libclang-dev
curl -fsSL https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-linux-x86_64.tar.gz | tar xz --strip-components=1 -C /usr/local
export CFLAGS_i686_unknown_linux_gnu=-msse2 CXXFLAGS_i686_unknown_linux_gnu=-msse2
rustup target add ${{ matrix.target }}
cargo build -p tmc --release --verbose --target ${{ matrix.target }}
'
sudo chown -R "$(id -u):$(id -g)" target "$HOME/.cargo-container"
- name: Get the version
id: get_version
shell: bash
run: echo "VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_OUTPUT
- name: Deploy
run: gsutil cp target/${{ matrix.target }}/release/tmc gs://${{ secrets.GCP_BUCKET }}/tmc-cli-rust/tmc-cli-rust-${{ matrix.target }}-${{ steps.get_version.outputs.VERSION }}