diff --git a/.dockerignore b/.dockerignore index b4f431c8..a0d88f54 100644 --- a/.dockerignore +++ b/.dockerignore @@ -12,3 +12,4 @@ src/cache_buster_data.json browser/target browser/cobertura.xml browser/docs +**/target diff --git a/.github/workflows/clippy-fmt.yml b/.github/workflows/clippy-fmt.yml index 16212b0e..638bebf4 100644 --- a/.github/workflows/clippy-fmt.yml +++ b/.github/workflows/clippy-fmt.yml @@ -12,54 +12,21 @@ jobs: fmt: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: ⚡ Cache - uses: actions/cache@v2 + - uses: actions/checkout@v4 + # Ensure rustfmt is installed and setup problem matcher + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - path: | - ~/.cargo/registry - ~/.cargo/git - node_modules - ./docs/openapi/node_modules - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable components: rustfmt - - name: Check with rustfmt - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - name: Rustfmt Check + uses: actions-rust-lang/rustfmt@v1 clippy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: ⚡ Cache - uses: actions/cache@v2 + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 with: - path: | - ~/.cargo/registry - ~/.cargo/git - node_modules - ./docs/openapi/node_modules - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable components: clippy - override: true - uses: actions/setup-node@v2 with: @@ -68,8 +35,5 @@ jobs: - name: Build frontend run: make frontend - - name: Check with Clippy - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --workspace --tests --all-features + - name: clippy Check + run: cargo clippy --workspace --tests --all-features diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 3ac1d7d5..343e626c 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -68,18 +68,7 @@ jobs: steps: - - uses: actions/checkout@v2 - - name: ⚡ Cache - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - node_modules - ./docs/openapi/node_modules - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - + - uses: actions/checkout@v4 - name: load env run: | @@ -92,12 +81,7 @@ jobs: with: node-version: "18.0.0" - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu - profile: minimal - override: true + - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: Build frontend run: make frontend diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1bc88f99..3e33086a 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -9,7 +9,7 @@ on: branches: - master - "*" - - '!gh-pages' + - "!gh-pages" jobs: build_and_test: @@ -17,9 +17,7 @@ jobs: fail-fast: false matrix: version: - #- 1.51.0 - stable - # - nightly name: ${{ matrix.version }} - x86_64-unknown-linux-gnu runs-on: ubuntu-latest @@ -55,7 +53,7 @@ jobs: maria: image: mariadb:10 - env: + env: MARIADB_USER: "maria" MARIADB_PASSWORD: "password" MARIADB_ROOT_PASSWORD: "password" @@ -69,17 +67,17 @@ jobs: - 3306:3306 steps: - - uses: actions/checkout@v2 - - name: ⚡ Cache - uses: actions/cache@v2 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - node_modules - ./docs/openapi/node_modules - target - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + - uses: actions/checkout@v4 + #- name: ⚡ Cache + # uses: actions/cache@v2 + # with: + # path: | + # ~/.cargo/registry + # ~/.cargo/git + # node_modules + # ./docs/openapi/node_modules + # target + # key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: configure GPG key if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'mCaptcha/mCaptcha' @@ -97,12 +95,7 @@ jobs: with: node-version: "18.0.0" - - name: Install ${{ matrix.version }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu - profile: minimal - override: true + - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: install nightwatch dep run: sudo apt-get install xvfb @@ -117,7 +110,8 @@ jobs: run: make env: POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}" - MARIA_DATABASE_URL: "${{ env.MARIA_DATABASE_URL }}" + MARIA_DATABASE_URL: + "${{ env.MARIA_DATABASE_URL }}" # - name: build frontend # run: make frontend diff --git a/Dockerfile b/Dockerfile index 12441fcf..5b1b7402 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ # SPDX-FileCopyrightText: 2023 Aravinth Manivannan # # SPDX-License-Identifier: AGPL-3.0-or-later - FROM node:18.0.0 as frontend RUN set -ex; \ apt-get update; \ @@ -21,33 +20,16 @@ COPY Makefile /src/ COPY scripts /src/scripts RUN make frontend -FROM rust:latest as planner -RUN cargo install cargo-chef -WORKDIR /src -COPY . /src/ -RUN cargo chef prepare --recipe-path recipe.json - -FROM rust:latest as cacher -WORKDIR /src/ -RUN cargo install cargo-chef -COPY --from=planner /src/recipe.json recipe.json -RUN cargo chef cook --release --recipe-path recipe.json - FROM rust:latest as rust WORKDIR /src COPY . . -COPY --from=cacher /src/target target -#COPY --from=cacher /src/db/db-core/target /src/db/db-core/target -#COPY --from=cacher /src/db/db-sqlx-postgres/target /src/db/db-sqlx-postgres/target -#COPY --from=cacher /src/db/db-migrations/target /src/db/db-migrations/target -#COPY --from=cacher /src/utils/cache-bust/target /src/utils/cache-bust/target COPY --from=frontend /src/static/cache/bundle/ /src/static/cache/bundle/ COPY --from=frontend /src/docs/openapi/dist/ /src/docs/openapi/dist/ RUN cargo --version RUN make cache-bust RUN cargo build --release -FROM debian:bullseye as mCaptcha +FROM debian:bookworm as mCaptcha LABEL org.opencontainers.image.source https://github.com/mCaptcha/mCaptcha RUN useradd -ms /bin/bash -u 1001 mcaptcha WORKDIR /home/mcaptcha