optimize ci build: use own dockerfile for dependencies + cache for builds #164
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
target/
|
||||||
|
db.sqlite
|
||||||
|
.history/
|
||||||
|
frontend/node_modules/*
|
||||||
|
/static/
|
||||||
|
/data-ergo/
|
@ -7,29 +7,35 @@ env:
|
|||||||
SSH_HOST: ${{ secrets.SSH_HOST }}
|
SSH_HOST: ${{ secrets.SSH_HOST }}
|
||||||
SSH_USER: ${{ secrets.SSH_USER }}
|
SSH_USER: ${{ secrets.SSH_USER }}
|
||||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
CARGO_INCREMENTAL: 0
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-frontend:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: rust:latest
|
container: git.hofer.link/ruderverein-donau-linz/rowing-ci:20240118
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
apt-get update -qq && apt-get install -y -qq sshpass musl musl-tools sqlite3 curl gnupg && mkdir -p /etc/apt/keyrings | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && apt-get update && apt-get install nodejs -y && apt-get install npm -y
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Run Test DB Script
|
- name: Run Test DB Script
|
||||||
run: ./test_db.sh
|
run: ./test_db.sh
|
||||||
|
|
||||||
|
- name: Set up cargo cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cargo build
|
cargo build
|
||||||
cd frontend && npm install && npm run build
|
cd frontend && npm install && npm run build
|
||||||
- name: Install dependencies
|
- name: Frontend tests
|
||||||
run: cd frontend && npm install
|
|
||||||
- name: Install Playwright Browsers
|
|
||||||
run: cd frontend && npx playwright install --with-deps
|
|
||||||
- name: Run Playwright tests
|
|
||||||
run: cd frontend && npx playwright test --workers 1
|
run: cd frontend && npx playwright test --workers 1
|
||||||
|
- name: Backend tests
|
||||||
|
run: cargo test --verbose
|
||||||
#- uses: actions/upload-artifact@v3
|
#- uses: actions/upload-artifact@v3
|
||||||
# if: always()
|
# if: always()
|
||||||
# with:
|
# with:
|
||||||
@ -37,61 +43,30 @@ jobs:
|
|||||||
# path: frontend/playwright-report/
|
# path: frontend/playwright-report/
|
||||||
# retention-days: 30
|
# retention-days: 30
|
||||||
|
|
||||||
test-backend:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container: rust:latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
apt-get update -qq && apt-get install -y -qq sshpass musl musl-tools sqlite3 curl gnupg && mkdir -p /etc/apt/keyrings | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && apt-get update && apt-get install nodejs -y && apt-get install npm -y
|
|
||||||
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: Run Test DB Script
|
|
||||||
run: ./test_db.sh
|
|
||||||
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
cargo build
|
|
||||||
cd frontend && npm install && npm run build
|
|
||||||
|
|
||||||
- name: Run Tests
|
|
||||||
run: cargo test --verbose
|
|
||||||
|
|
||||||
deploy-staging:
|
deploy-staging:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: rust:latest
|
container: git.hofer.link/ruderverein-donau-linz/rowing-ci:20240118
|
||||||
needs: [test_frontend, test_backend]
|
needs: [test]
|
||||||
if: github.ref == 'refs/heads/staging'
|
if: github.ref == 'refs/heads/staging'
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
rustup target add $CARGO_TARGET
|
|
||||||
apt-get update -qq && apt-get install -y -qq pkg-config sshpass musl musl-tools sqlite3 curl gnupg libssl-dev
|
|
||||||
|
|
||||||
# Handling NodeSource GPG key
|
|
||||||
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key -o nodesource.gpg.key
|
|
||||||
if [ -f /etc/apt/keyrings/nodesource.gpg ]; then
|
|
||||||
rm /etc/apt/keyrings/nodesource.gpg
|
|
||||||
fi
|
|
||||||
gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg nodesource.gpg.key
|
|
||||||
|
|
||||||
# Adding NodeSource repository
|
|
||||||
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
|
|
||||||
|
|
||||||
# Installing Node.js and npm
|
|
||||||
apt-get update
|
|
||||||
apt-get install nodejs -y
|
|
||||||
apt-get install npm -y
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Run Test DB Script
|
- name: Run Test DB Script
|
||||||
run: ./test_db.sh
|
run: ./test_db.sh
|
||||||
|
|
||||||
|
- name: Set up cargo cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cargo build --release --target $CARGO_TARGET
|
cargo build --release --target $CARGO_TARGET
|
||||||
@ -122,21 +97,27 @@ jobs:
|
|||||||
|
|
||||||
deploy-main:
|
deploy-main:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: rust:latest
|
container: git.hofer.link/ruderverein-donau-linz/rowing-ci:20240118
|
||||||
needs: [test_frontend, test_backend]
|
needs: [test]
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
steps:
|
steps:
|
||||||
- name: Setup Environment
|
|
||||||
run: |
|
|
||||||
rustup target add $CARGO_TARGET
|
|
||||||
apt-get update -qq && apt-get install -y -qq pkg-config sshpass musl musl-tools sqlite3 curl gnupg libssl-dev && mkdir -p /etc/apt/keyrings | curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && apt-get update && apt-get install nodejs -y && apt-get install npm -y
|
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Run Test DB Script
|
- name: Run Test DB Script
|
||||||
run: ./test_db.sh
|
run: ./test_db.sh
|
||||||
|
|
||||||
|
- name: Set up cargo cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
cargo build --release --target $CARGO_TARGET
|
cargo build --release --target $CARGO_TARGET
|
||||||
|
26
Dockerfile
Normal file
26
Dockerfile
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# This dockerfile is used as basis for the CI jobs.
|
||||||
|
# Process to renew it:
|
||||||
|
# 0. Login to gitea docker registry: `docker login git.hofer.link`
|
||||||
|
# 1. Build the image `docker build .`
|
||||||
|
# 2. Tag the image: `docker tag <id> git.hofer.link/ruderverein-donau-linz/rowing-ci:<date>`
|
||||||
|
# 3. Push the image: `docker push git.hofer.link/ruderverein-donau-linz/rowing-ci:<date>`
|
||||||
|
|
||||||
|
|
||||||
|
FROM rust:1.75.0
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y sqlite3
|
||||||
|
|
||||||
|
# nodejs
|
||||||
|
RUN apt-get install -y curl && \
|
||||||
|
curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
|
||||||
|
apt-get install -y nodejs
|
||||||
|
|
||||||
|
# playwright
|
||||||
|
RUN npx playwright install --with-deps
|
||||||
|
|
||||||
|
# deployment
|
||||||
|
RUN rustup target add x86_64-unknown-linux-musl
|
||||||
|
RUN apt-get install -y -qq pkg-config sshpass musl musl-tools curl gnupg libssl-dev
|
||||||
|
|
||||||
|
# TEMPORARY act workaround (otherwise gitea cache is not working)
|
||||||
|
RUN apt-get install -y zstd
|
@ -1,17 +1,14 @@
|
|||||||
# Build
|
# Build
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
1. `cd frontend`
|
1. `cd frontend`
|
||||||
2. `npm install`
|
2. `npm install`
|
||||||
3. `npm run (watch/build)`
|
3. `npm run (watch/build)`
|
||||||
|
|
||||||
# Run
|
# Run
|
||||||
|
|
||||||
## Backend
|
## Backend
|
||||||
1. `cargo r`
|
1. `cargo r`
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
- `npx playwright test --workers 1 --project firefox`
|
- `npx playwright test --workers 1 --project firefox`
|
||||||
- Nice UI: `--ui`
|
- Nice UI: `--ui`
|
||||||
@ -19,4 +16,3 @@
|
|||||||
|
|
||||||
## Backend (Unit + Integration)
|
## Backend (Unit + Integration)
|
||||||
`cargo t`
|
`cargo t`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user