-
Notifications
You must be signed in to change notification settings - Fork 2
164 lines (161 loc) · 5.32 KB
/
dctl_cli.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
name: dctl CI
run-name: ${{ github.actor }} launch dctl tests
on:
pull_request:
push:
branches:
- main
tags:
- '*.*.*'
jobs:
tests:
if: github.event_name == 'push' || github.event_name == 'pull_request'
name: Test and Code coverage
runs-on: ubuntu-latest
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v4
- name: install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install grcov
run: rustup component add llvm-tools-preview && cargo install grcov
- name: "Prepare cache"
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
cli/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: run tests
run: cargo test
env:
RUSTFLAGS: '-Cinstrument-coverage'
- name: Run grcov
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
- name: upload coverage
uses: codecov/codecov-action@v3
with:
files: lcov.info
flags: unittests
name: codecov-dctl
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
tests_for_release:
if: startsWith(github.ref, 'refs/tags/')
name: Test and Build dctl
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: "ubuntu-latest"
target: x86_64-unknown-linux-gnu
- os: "ubuntu-latest"
target: x86_64-unknown-linux-musl
- os: "macos-latest"
target: x86_64-apple-darwin
- os: "macos-latest"
target: aarch64-apple-darwin
- os: "windows-latest"
target: x86_64-pc-windows-msvc
- os: "windows-latest"
target: x86_64-pc-windows-gnu
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v4
- name: install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: "Prepare cache"
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
cli/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install target
- name: install target
run: rustup target add ${{ matrix.target }}
# Test
- name: run tests --release
run: cargo test --release
# Build only on tag
- name: run build --release
run: cargo build --release --target ${{ matrix.target }}
# Save build
- if: runner.os != 'Windows'
name: Tar files
run: tar cvf dctl-${{ runner.os }}-${{ matrix.target }}.tar ./target/${{ matrix.target }}/release/dctl
- if: runner.os == 'Windows'
name: Tar files
run: tar cvf dctl-${{ runner.os }}-${{ matrix.target }}.tar ./target/${{ matrix.target }}/release/dctl.exe
- name: save compressed build
uses: actions/upload-artifact@v4
with:
name: dctl-${{ runner.os }}-${{ matrix.target }}.tar
path: cli/dctl-${{ runner.os }}-${{ matrix.target }}.tar
retention-days: 1
release:
name: Create Release
runs-on: ubuntu-latest
needs: tests_for_release
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v4
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: if ${{ github.event_name == 'pull_request' }} then true else false
prerelease: if ${{ startsWith(github.ref, 'refs/tags/rc*') }} then true else false
upload_artifacts:
name: Upload Release Assets
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: "ubuntu-latest"
target: x86_64-unknown-linux-gnu
- os: "ubuntu-latest"
target: x86_64-unknown-linux-musl
- os: "macos-latest"
target: x86_64-apple-darwin
- os: "macos-latest"
target: aarch64-apple-darwin
- os: "windows-latest"
target: x86_64-pc-windows-msvc
- os: "windows-latest"
target: x86_64-pc-windows-gnu
needs: release
steps:
- name: Download Release Asset
uses: actions/download-artifact@v4
with:
name: dctl-${{ runner.os }}-${{ matrix.target }}.tar
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_name: dctl-${{ runner.os }}-${{ matrix.target }}.tar
asset_path: ./dctl-${{ runner.os }}-${{ matrix.target }}.tar
asset_content_type: application/octet-stream