-
Notifications
You must be signed in to change notification settings - Fork 2
137 lines (120 loc) · 3.64 KB
/
test.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
on:
push:
tags:
- v*
branches:
- main
pull_request:
workflow_dispatch:
inputs:
publish-tag:
type: string
required: false
description: "Publish a tag"
name: CI
jobs:
build_and_test:
name: Rust project
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
bin: docker-repack
name: docker-repack-Linux-x86_64.tar.gz
- os: macOS-latest
bin: docker-repack
name: docker-repack-Darwin-x86_64.tar.gz
- os: windows-latest
bin: docker-repack.exe
name: docker-repack-Windows-x86_64.zip
env:
RUST_BACKTRACE: "1"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
release_profile: "lto"
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.publish-tag || null }}
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.7
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache-on-failure: 'false'
- name: Build
run: cargo build --all-targets
- name: Test
run: cargo test
- name: Integration test
run: cargo run -- "docker://python:3.11-slim" oci://test-image/ --target-size="500MB" --compression-level=1 --platform=linux/arm64
- name: Build release
if: startsWith(github.ref, 'refs/tags/') || inputs.publish-tag
run: cargo build --profile=${{env.release_profile}}
- name: Package
if: startsWith(github.ref, 'refs/tags/') || inputs.publish-tag
shell: bash
run: |
strip target/${{env.release_profile}}/${{ matrix.bin }}
cd target/${{env.release_profile}}
if [[ "${{ matrix.os }}" == "windows-latest" ]]
then
7z a ../../${{ matrix.name }} ${{ matrix.bin }}
else
tar czvf ../../${{ matrix.name }} ${{ matrix.bin }}
fi
cd -
- name: Archive binaries
uses: actions/upload-artifact@v4
if: startsWith(github.ref, 'refs/tags/') || inputs.publish-tag
with:
name: build-${{ matrix.name }}
path: ${{ matrix.name }}
create_release:
name: Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/') || inputs.publish-tag
needs: [ build_and_test ]
permissions:
contents: write
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ inputs.publish-tag || null }}
- uses: actions/download-artifact@v4
- name: Publish
uses: softprops/action-gh-release@v2
with:
tag_name: "${{ inputs.publish-tag }}"
draft: false
files: |
**/*.tar.gz
**/*.zip
checks:
name: Checks
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: "1"
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ inputs.publish-tag || null }}
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.7
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
cache-on-failure: 'false'
- name: Run cargo fmt
if: success() || failure()
run: cargo fmt --all -- --check
- name: Run cargo check
if: success() || failure()
run: cargo check
- if: success() || failure()
run: cargo clippy --all-targets --all-features -- -D warnings