Skip to content

Commit 16002fa

Browse files
committed
ci: Refactor workflows
1 parent 7e3bcd4 commit 16002fa

File tree

5 files changed

+119
-119
lines changed

5 files changed

+119
-119
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/vingo.yml

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,43 @@
1-
---
2-
name: Vingo format and clipy check
1+
name: "vingo: check style"
32

43
on:
54
push:
6-
branches:
7-
- main
85
paths:
9-
- .github/workflows/vingo.yml
10-
- 'vingo/**/*.rs'
6+
- ".github/workflows/vingo.yml"
7+
- "vingo/**"
118
pull_request:
129
paths:
13-
- .github/workflows/vingo.yml
14-
- 'vingo/**/*.rs'
10+
- ".github/workflows/vingo.yml"
11+
- "vingo/**"
1512
workflow_dispatch:
1613

1714
jobs:
18-
1915
formatting:
20-
runs-on: ubuntu-latest
16+
runs-on: "ubuntu-latest"
2117
steps:
22-
- uses: actions/checkout@v4
23-
- name: Install latest rust toolchain
24-
uses: actions-rs/toolchain@v1.0.6
18+
- uses: "actions/checkout@v4"
19+
20+
- uses: "actions-rs/toolchain@v1.0.6"
2521
with:
26-
toolchain: stable
27-
components: rustfmt
22+
toolchain: "stable"
23+
components: "rustfmt"
2824
override: true
2925

30-
- name: Check formatting
31-
working-directory: vingo/
32-
run: cargo fmt -- --check
26+
- name: "cargo fmt"
27+
working-directory: "vingo/"
28+
run: "cargo fmt -- --check"
3329

3430
clipy:
35-
runs-on: ubuntu-latest
31+
runs-on: "ubuntu-latest"
3632
steps:
37-
- uses: actions/checkout@v4
38-
- name: Install latest rust toolchain
39-
uses: actions-rs/toolchain@v1.0.6
33+
- uses: "actions/checkout@v4"
34+
35+
- uses: "actions-rs/toolchain@v1.0.6"
4036
with:
41-
toolchain: stable
42-
components: clippy
37+
toolchain: "stable"
38+
components: "clippy"
4339
override: true
44-
- name: Clippy check
45-
working-directory: vingo/
46-
run: cargo clippy --locked --all-targets --all-features
40+
41+
- name: "cargo clippy"
42+
working-directory: "vingo/"
43+
run: "cargo clippy --locked --all-targets --all-features"

.github/workflows/vinvoor.yml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
name: Vinvoor Format, Lint & Typecheck
1+
name: "vinvoor: format, lint and typecheck"
22

33
on:
44
push:
5-
branches:
6-
- main
5+
paths:
6+
- ".github/workflows/vinvoor.yml"
7+
- "vinvoor/**"
78
pull_request:
9+
paths:
10+
- ".github/workflows/vinvoor.yml"
11+
- "vinvoor/**"
12+
workflow_dispatch:
813

914
jobs:
10-
format-and-lint:
11-
runs-on: ubuntu-latest
12-
15+
format-lint-typecheck:
16+
runs-on: "ubuntu-latest"
1317
steps:
14-
- name: Checkout code
15-
uses: actions/checkout@v4
16-
17-
- name: Setup Node.js
18-
uses: actions/setup-node@v3
18+
- uses: "actions/checkout@v4"
19+
- uses: "actions/setup-node@v3"
1920
with:
20-
node-version: 22.8.0
21-
22-
- name: Install pnpm
23-
run: npm install -g pnpm
21+
node-version: "22.8.0"
22+
- run: "npm install -g pnpm"
2423

25-
- name: Install dependencies
26-
run: pnpm install
27-
working-directory: vinvoor/
24+
- run: "pnpm install"
25+
working-directory: "vinvoor/"
2826

29-
- name: Run format & lint
30-
run: pnpm eslint .
31-
working-directory: vinvoor/
27+
- name: "format and lint"
28+
working-directory: "vinvoor/"
29+
run: "pnpm eslint ."
3230

33-
- name: Run typecheck
34-
run: pnpm tsc --noEmit
35-
working-directory: vinvoor/
31+
- name: "typecheck"
32+
working-directory: "vinvoor/"
33+
run: "pnpm tsc --noEmit"

.github/workflows/zess_docker.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: "zess: docker build and (main only) push"
2+
3+
on:
4+
push:
5+
paths:
6+
- ".github/workflows/zess_docker.yml"
7+
- "vingo/**"
8+
- "vinvoor/**"
9+
- "Dockerfile"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/zess_docker.yml"
13+
- "Dockerfile"
14+
- "vingo/**"
15+
- "vinvoor/**"
16+
workflow_dispatch:
17+
18+
concurrency:
19+
group: "docker-${{ github.ref }}"
20+
cancel-in-progress: true
21+
22+
jobs:
23+
build-and-push:
24+
runs-on: "ubuntu-latest"
25+
permissions:
26+
contents: "read"
27+
packages: "write"
28+
steps:
29+
- uses: "actions/checkout@v4"
30+
31+
- uses: "docker/setup-buildx-action@v3"
32+
33+
- name: "docker build"
34+
run: "docker build . -t ghcr.io/zeuswpi/zess:pr-${{ github.sha }}"
35+
36+
- name: "docker login"
37+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
38+
uses: "docker/login-action@v3"
39+
with:
40+
registry: "ghcr.io"
41+
username: "${{ github.actor }}"
42+
password: "${{ secrets.GITHUB_TOKEN }}"
43+
44+
- name: "docker tag latest"
45+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
46+
run: "docker tag ghcr.io/zeuswpi/zess:pr-${{ github.sha }} ghcr.io/zeuswpi/zess:latest"
47+
48+
- name: "docker push latest"
49+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
50+
run: "docker push --all-tags ghcr.io/zeuswpi/zess"

Dockerfile

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
# Build backend
2-
FROM rust:1.81-alpine3.20 as build_backend
3-
1+
FROM docker.io/rust:1.81-alpine3.20 AS base-rust
42
RUN apk add upx musl-dev
3+
RUN cargo install cargo-chef@0.1.72
4+
WORKDIR /build
5+
6+
FROM docker.io/node:20.15.1-alpine3.20 AS base-node
7+
RUN npm install -g pnpm
8+
WORKDIR /build
59

6-
WORKDIR /
710

8-
COPY vingo/Cargo.* ./
11+
FROM base-rust AS vingo-recipe
912

10-
COPY vingo/migration migration/
13+
COPY vingo/ ./
14+
RUN cargo chef prepare --recipe-path=recipe.json
1115

12-
COPY vingo/src src/
1316

17+
FROM base-rust AS vingo-build
18+
19+
COPY --from=vingo-recipe /build/recipe.json recipe.json
20+
RUN cargo chef cook --release --recipe-path=recipe.json
21+
22+
COPY vingo/ ./
1423
RUN cargo build --release
1524

1625
RUN upx --best --lzma target/release/vingo
1726

18-
# Build frontend
19-
FROM node:20.15.1-alpine3.20 as build_frontend
2027

21-
WORKDIR /
28+
FROM base-node AS vinvoor-build
2229

23-
RUN npm install -g pnpm
30+
WORKDIR /build
2431

2532
COPY vinvoor/package.json package.json
26-
2733
COPY vinvoor/pnpm-lock.yaml pnpm-lock.yaml
28-
29-
RUN pnpm install
34+
RUN pnpm i
3035

3136
COPY vinvoor/ ./
32-
3337
COPY vinvoor/production.env .env
34-
3538
RUN pnpm run build
3639

37-
# End container
38-
FROM alpine:3.20
3940

40-
WORKDIR /
41+
FROM alpine:3.20 AS runner
4142

42-
COPY --from=build_backend target/release/vingo .
43-
COPY --from=build_frontend /dist public
43+
WORKDIR /work
44+
COPY --from=vingo-build /build/target/release/vingo vingo
45+
COPY --from=vinvoor-build /build/dist/ public/
4446

4547
ENV DEVELOPMENT=FALSE
46-
4748
EXPOSE 4000
48-
4949
ENTRYPOINT ["./vingo"]

0 commit comments

Comments
 (0)