-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (77 loc) · 3.13 KB
/
test.yaml
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
name: test
on:
push:
branches:
- main
pull_request:
env:
VERSION: "0.1.${{ github.run_number }}"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-container:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install rust tool chain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
target: x86_64-unknown-linux-musl
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install cross
run: cargo binstall -y cross
- name: Build project in x86_64-unknown-linux-musl and aarch64-unknown-linux-musl
run: |
mkdir -p ./bin
cross build --target x86_64-unknown-linux-musl && mv ./target/x86_64-unknown-linux-musl/debug/httpget ./bin/httpget.x86_64
cross build --target x86_64-unknown-linux-musl --features tls && mv ./target/x86_64-unknown-linux-musl/debug/httpget ./bin/httpget-tls.x86_64
cross build --target aarch64-unknown-linux-musl && mv ./target/aarch64-unknown-linux-musl/debug/httpget ./bin/httpget.amd64
cross build --target aarch64-unknown-linux-musl --features tls && mv ./target/aarch64-unknown-linux-musl/debug/httpget ./bin/httpget-tls.amd64
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build the container
uses: docker/build-push-action@v4
with:
context: ./bin
file: ./Dockerfile.release
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install rust tool chain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: rustfmt, clippy
target: x86_64-unknown-linux-musl
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-test-${{ hashFiles('**/Cargo.lock') }}
- name: Install cargo-binstall
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
- name: Install cross
run: cargo binstall -y cross
- name: Lint the code
run: cargo clippy
- name: Run the security audit check
run: cargo audit
- name: Run the tests with the static target for the debug build
run: cross test --target x86_64-unknown-linux-musl
- name: Run the test for arm64 target
run: cross test --target aarch64-unknown-linux-musl