The CI was failing because the rust:latest container doesn't have Node.js, but the actions/checkout@v4 action requires Node.js to run. Error: 'exec: node: executable file not found in /home/asoliver/.local/bin/:/home/asoliver/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/home/asoliver/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/rustup/bin' Solution: - Install Node.js before running checkout action - For rust:latest containers: use NodeSource repository - For docker:latest containers: use apk package manager This allows the GitHub Actions checkout action to work in Forgejo.
102 lines
2.3 KiB
YAML
102 lines
2.3 KiB
YAML
name: Lint and Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- develop
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- develop
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
RUST_BACKTRACE: 1
|
|
|
|
jobs:
|
|
lint:
|
|
name: Lint
|
|
runs-on: docker
|
|
container:
|
|
image: rust:latest
|
|
steps:
|
|
- name: Install Node.js
|
|
run: |
|
|
apt-get update && apt-get install -y curl
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
apt-get install -y nodejs
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update && apt-get install -y pkg-config libssl-dev
|
|
|
|
- name: Run rustfmt
|
|
working-directory: ./backend
|
|
run: |
|
|
cargo fmt --all -- --check
|
|
|
|
- name: Run clippy
|
|
working-directory: ./backend
|
|
run: |
|
|
cargo clippy --all-targets --all-features -- -D warnings
|
|
|
|
build:
|
|
name: Build
|
|
runs-on: docker
|
|
container:
|
|
image: rust:latest
|
|
needs: lint
|
|
steps:
|
|
- name: Install Node.js
|
|
run: |
|
|
apt-get update && apt-get install -y curl
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
apt-get install -y nodejs
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
apt-get update && apt-get install -y pkg-config libssl-dev
|
|
|
|
- name: Build project
|
|
working-directory: ./backend
|
|
run: |
|
|
cargo build --release --verbose
|
|
|
|
- name: Run tests
|
|
working-directory: ./backend
|
|
run: |
|
|
cargo test --verbose
|
|
|
|
docker-build:
|
|
name: Docker Build
|
|
runs-on: docker
|
|
container:
|
|
image: docker:latest
|
|
needs: build
|
|
services:
|
|
docker:
|
|
image: docker:dind
|
|
steps:
|
|
- name: Install Node.js
|
|
run: |
|
|
apk add --no-cache nodejs npm
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Build Docker image
|
|
working-directory: ./backend
|
|
run: |
|
|
docker build -f docker/Dockerfile -t normogen-backend:test .
|
|
|
|
- name: Build Docker image (dev)
|
|
working-directory: ./backend
|
|
run: |
|
|
docker build -f docker/Dockerfile.dev -t normogen-backend:dev-test .
|