forked from kubecfg/kubit
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (125 loc) · 4.3 KB
/
rust.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
name: Rust
on:
push:
branches: ["main"]
tags:
- v*.*.*
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
- name: Format
run: cargo fmt --all --check
- name: Lint
run: cargo clippy -- -D warnings
- name: Build
run: cargo build
- name: Generate
run: cargo run -- manifests --crd-dir kustomize/crd/bases
- name: Diff
run: test -z "$(git status --porcelain)" || (echo 'Changes detected after generating manifests'; git status; git --no-pager diff; false)
- name: Run unit tests
run: cargo test --lib
integration_tests:
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
- uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 # v2.4.0
with:
cluster-name: "kubit-test-cluster-1"
- name: Run all tests
run: cargo test
pack:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
# Allows pushing to the GitHub Container Registry
packages: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Set up Depot Docker Build
uses: depot/setup-action@eb2efd6287c794d456be5e1a7963fa8772c39ce5 # v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3
- name: Login to GHCR
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: github.event_name != 'pull_request'
- name: Build
if: "!github.event.pull_request.head.repo.fork"
uses: depot/build-push-action@e7743ee6585d261968c7ae0ef64977ee98c09d74 # v1
with:
project: v8n5whjnsb
context: .
platforms: linux/amd64,linux/arm64
push: false
tags: ghcr.io/kubecfg/kubit:latest
load: true
- name: Test
if: "!github.event.pull_request.head.repo.fork"
run: |
docker run --rm ghcr.io/kubecfg/kubit:latest --version
- name: Push
uses: depot/build-push-action@e7743ee6585d261968c7ae0ef64977ee98c09d74 # v1
with:
project: v8n5whjnsb
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/kubecfg/kubit:latest
if: github.event_name != 'pull_request'
create_release:
name: Create Release
runs-on: ubuntu-latest
needs: [build, pack]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Create Release
id: create_release
uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # renovate: tag=v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: true
prerelease: false
release:
# Allow depot permissions to GHCR
permissions:
contents: read
id-token: write
packages: write
needs: [pack, build]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Set up Depot Docker Build
uses: depot/setup-action@eb2efd6287c794d456be5e1a7963fa8772c39ce5 # v1
- name: Login to GHCR
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: release_image
uses: depot/build-push-action@e7743ee6585d261968c7ae0ef64977ee98c09d74 # v1
with:
project: v8n5whjnsb
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/kubecfg/kubit:${{ github.ref_name }}