-
-
Notifications
You must be signed in to change notification settings - Fork 25
136 lines (121 loc) · 3.87 KB
/
Copy pathbuild.yml
File metadata and controls
136 lines (121 loc) · 3.87 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
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
name: Build, Test, Lint & Package
on:
workflow_dispatch:
inputs:
release:
type: boolean
description: 'Build with release profile'
default: false
workflow_call:
inputs:
release:
type: boolean
default: false
outputs:
build:
value: ${{ jobs.build.outputs.build }}
tests:
value: ${{ jobs.build.outputs.tests }}
clippy:
value: ${{ jobs.build.outputs.clippy }}
format:
value: ${{ jobs.build.outputs.format }}
doc:
value: ${{ jobs.build.outputs.doc }}
shear:
value: ${{ jobs.build.outputs.shear }}
artifact-url:
value: ${{ jobs.build.outputs.artifact-url }}
version:
value: ${{ jobs.build.outputs.version }}
jobs:
build:
name: Build, Test, Lint and Package
runs-on: ubuntu-latest
outputs:
build: ${{ steps.build.outcome }}
tests: ${{ steps.tests.outcome }}
clippy: ${{ steps.clippy.outcome }}
format: ${{ steps.format.outcome }}
doc: ${{ steps.doc.outcome }}
shear: ${{ steps.shear.outcome }}
version: ${{ steps.create-artifacts.outputs.VERSION}}
artifact-url: ${{ steps.upload-x86.outputs.artifact-url }}
env:
build-type: ${{ inputs.release && 'release' || 'dev' }}
steps:
- uses: actions/checkout@v6
- name: Restore cached cargo dependencies
id: deps-cache
if: ${{ !inputs.release }}
uses: actions/cache/restore@v5
with:
path: |
~/.cargo/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
# TODO: rustup target add aarch64-unknown-linux-gnu
# Linting tools
cargo install cargo-shear
cargo fetch
- name: Build
id: build
if: always()
run: cargo build --profile ${{ env.build-type }}
- name: Tests
id: tests
if: always()
run: cargo test --profile ${{ env.build-type }}
- name: Clippy
id: clippy
if: always()
run: cargo clippy --profile ${{ env.build-type }} --no-deps -- --deny warnings
- name: Format
id: format
if: always()
run: cargo fmt -- --check
- name: Doc
id: doc
if: always()
env:
CARGO_BUILD_RUSTDOCFLAGS: "--deny warnings"
run: cargo doc --profile ${{ env.build-type }} --document-private-items --no-deps
- name: Shear
if: always()
id: shear
run: cargo shear
- name: Create artifacts
id: create-artifacts
if: ${{ steps.build.outcome == 'success' }}
run: |
version=$(cargo pkgid | sed 's/.*#//')
echo "VERSION=$version" >> "$GITHUB_OUTPUT"
if [ "${{ env.build-type }}" == "release" ]; then
buildtype="release"
else
buildtype="debug"
fi
artifact_x86=linux-enable-ir-emitter-${version}-${buildtype}-x86-64.tar.gz
echo "ARTIFACT_X86=$artifact_x86" >> "$GITHUB_OUTPUT"
tar -czvf ${artifact_x86} -C target/${buildtype} linux-enable-ir-emitter
- name: Upload x86
id: upload-x86
if: ${{ steps.build.outcome == 'success' }}
uses: actions/upload-artifact@v6
with:
name: ${{ steps.create-artifacts.outputs.ARTIFACT_X86 }}
path: ${{ steps.create-artifacts.outputs.ARTIFACT_X86 }}
if-no-files-found: error
- name: Save cached cargo dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: |
~/.cargo/
target/
key: ${{ steps.deps-cache.outputs.cache-primary-key }}