-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (160 loc) · 5.68 KB
/
build.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Build
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
versionning:
name: Versionning
runs-on: ubuntu-latest
outputs:
version: ${{ steps.genver.outputs.version }}
release: ${{ steps.genver.outputs.release }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate Version
id: genver
run: |
VERSION=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }}-pre --dev-branch=main)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION : $VERSION"
RELEASE=$(docker run --rm -v $(pwd):/repo codacy/git-version /bin/git-version --folder=/repo --release-branch=${{ github.ref_name }} --dev-branch=main)
echo "release=$RELEASE" >> $GITHUB_OUTPUT
echo "RELEASE : $RELEASE"
echo "Version :" >> $GITHUB_STEP_SUMMARY
echo "$VERSION" >> $GITHUB_STEP_SUMMARY
echo "Release :" >> $GITHUB_STEP_SUMMARY
echo "$RELEASE" >> $GITHUB_STEP_SUMMARY
docker:
name: Docker image Build
runs-on: ubuntu-latest
needs:
- versionning
strategy:
fail-fast: false
matrix:
image:
- { path: pdc-update, name: armonik_pdc_update, platforms: "linux/amd64" }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_LOGIN }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
file: "${{ matrix.image.path }}/Dockerfile"
context: "${{ matrix.image.path }}"
platforms: "${{ matrix.image.platforms }}"
push: true
tags: |
dockerhubaneo/${{ matrix.image.name }}:${{ needs.versionning.outputs.version }}
rust:
name: Rust Build and Test
strategy:
fail-fast: false
matrix:
project:
- pdc-update
target:
# Linux Musl
- { platform: aarch64-unknown-linux-musl, os: linux, runner: ubuntu-latest, run: true }
- { platform: arm-unknown-linux-musleabi, os: linux, runner: ubuntu-latest, run: true }
- { platform: i686-unknown-linux-musl, os: linux, runner: ubuntu-latest, run: true }
- { platform: x86_64-unknown-linux-musl, os: linux, runner: ubuntu-latest, run: true }
# Windows
- { platform: aarch64-pc-windows-msvc, os: windows, runner: windows-latest, run: false }
- { platform: i686-pc-windows-msvc, os: windows, runner: windows-latest, run: true }
- { platform: x86_64-pc-windows-msvc, os: windows, runner: windows-latest, run: true }
toolchain:
- stable
- nightly
runs-on: ${{ matrix.target.runner }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: taiki-e/install-action@v2
with:
tool: protoc,sccache
- name: Install toolchain
if: ${{ !contains(matrix.toolchain, 'nightly') }}
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target.platform }}
toolchain: ${{ matrix.toolchain }}
components: rust-src,rust-docs,rustfmt,clippy
- name: Install toolchain (with miri)
if: contains(matrix.toolchain, 'nightly')
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target.platform }}
toolchain: ${{ matrix.toolchain }}
components: rust-src,rust-docs,rustfmt,clippy,miri
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target.platform }}
- name: Setup Cache
uses: Swatinem/[email protected]
with:
shared-key: "build-${{ matrix.project }}-${{ matrix.toolchain }}-${{ matrix.target.platform }}"
workspaces: "${{ matrix.project }}"
- name: Build
working-directory: "${{ matrix.project }}"
run: |
cargo build --all --locked
- name: Test
if: matrix.target.run
working-directory: "${{ matrix.project }}"
run: |
cargo test --all --locked
- name: Test Release
if: matrix.target.run
working-directory: "${{ matrix.project }}"
run: |
cargo test --all --locked --release
- name: Test Miri
if: contains(matrix.toolchain, 'nightly')
working-directory: "${{ matrix.project }}"
run: |
cargo miri test --all --locked
- name: Format
working-directory: "${{ matrix.project }}"
run: |
cargo fmt --all --check
- name: Doc
if: matrix.target.os == 'linux'
working-directory: "${{ matrix.project }}"
run: |
RUSTDOCFLAGS="-Dwarnings" cargo doc
- name: Example
if: matrix.target.os == 'linux' && matrix.target.run
working-directory: "${{ matrix.project }}"
timeout-minutes: 1
run: |
set -x
for example in examples/*.rs; do
if [ -e "$example" ]; then
example="${example#examples/}"
example="${example%.rs}"
RUST_LOG=trace cargo run --locked --example "$example"
fi
done
- name: Clippy
working-directory: "${{ matrix.project }}"
run: |
cargo clippy --all --no-deps -- -Dwarnings -Dunused-crate-dependencies