-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (137 loc) · 4.34 KB
/
rollout-dashboard.yaml
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
name: Rollout dashboard
on:
push:
branches:
- main
paths:
- rollout-dashboard/**
- .github/**
pull_request:
paths:
- rollout-dashboard/**
- .github/**
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test-backend:
name: Test rollout dashboard backend
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Set month and year for cache key
id: date
run: echo "date=$(date +'%Y-%m')" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@v4
- name: Move backend files to source root
run: mv -f rollout-dashboard/server/* .
- name: Cache Cargo stuff once a month for faster execution
uses: actions/cache@v3
with:
key: cargo-build-deps-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ steps.date.outputs.date }}
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/debug/build
target/debug/deps
target/debug/.fingerprint
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Security audit
uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: cargo machete
run: |
set -e
which cargo-machete || cargo install cargo-machete
cargo machete
- name: cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
- name: cargo test
uses: actions-rs/cargo@v1
with:
command: test
test-frontend:
if: github.event_name == 'pull_request'
name: Test rollout dashboard frontend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Move frontend files to source root
run: mv -f rollout-dashboard/frontend/* .
- name: prepare NPM for CI
run: npm ci
- name: Security audit (optional for now)
run: npm audit || true
- name: build frontend
run: npm run build
- name: run tests on frontend
run: npm run check
build-rollout-dashboard-container:
name: Build rollout dashboard container
if: github.event_name == 'pull_request'
needs: [test-backend, test-frontend]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: metadata
with:
images: ghcr.io/${{ github.repository }}/cache
tags: |
type=sha,format=long
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: int128/kaniko-action@v1
name: Create rollout-dashboard container
with:
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache: true
cache-repository: ghcr.io/${{ github.repository }}/cache
context: rollout-dashboard
publish-rollout-dashboard-container:
name: Publish rollout dashboard container
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
id: metadata
with:
images: ghcr.io/${{ github.repository }}/rollout-dashboard
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,format=long
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: int128/kaniko-action@v1
name: Create and publish rollout-dashboard container
with:
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
cache: true
cache-repository: ghcr.io/${{ github.repository }}/cache
context: rollout-dashboard