From 35f61b1533b3c9cac76ce2ab161812da95957ced Mon Sep 17 00:00:00 2001 From: Guilherme Pereira Date: Wed, 2 Oct 2024 20:45:38 +0100 Subject: [PATCH 1/2] Update ci --- .github/workflows/docker.yml | 20 +++++----- .github/workflows/functional.yml | 35 +++++++++-------- .github/workflows/rust.yml | 65 +++++++++++++++++++++----------- 3 files changed, 72 insertions(+), 48 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 2458479eb..e8e458145 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,8 @@ name: Docker Publish on: - release: - types: [created] + release: + types: [created] jobs: build: @@ -10,19 +10,19 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: - push: true - tags: dlsz/floresta:latest + push: true + tags: dlsz/floresta:latest diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml index 4b238e5d6..6aad70df8 100644 --- a/.github/workflows/functional.yml +++ b/.github/workflows/functional.yml @@ -1,21 +1,26 @@ # runs our functinal tests from tests/ on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] + push: + pull_request: + branches: ["master"] jobs: - functional: - name: functional - runs-on: ubuntu-latest + functional: + name: Functional + runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: prepare environment - run: sudo apt-get install -y python3-pip && pip3 install -r tests/requirements.txt - - name: build - run: cargo build - - name: run functional tests - run: python tests/run_tests.py + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: sudo apt-get install -y python3-pip && pip3 install -r tests/requirements.txt + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + + - name: Build Floresta + run: cargo build + + - name: Run functional tests + run: python tests/run_tests.py diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b45632bff..c593c2127 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -2,9 +2,8 @@ name: Rust on: push: - branches: [ "master" ] pull_request: - branches: [ "master" ] + branches: ["master"] env: CARGO_TERM_COLOR: always @@ -14,17 +13,23 @@ jobs: runs-on: ubuntu-latest steps: - - name: install nightly rust - run: rustup install nightly; rustup +nightly component add rustfmt clippy - - # cargo fmt - - uses: actions/checkout@v3 - - name: fmt - run: cargo +nightly fmt --all --check - - # run cargo clippy - - name: Clippy - run: cargo +nightly clippy --all-targets + - uses: actions/checkout@v4 + + - name: Install latest nightly + uses: dtolnay/rust-toolchain@nightly + with: + components: rustfmt, clippy + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + + - name: Run cargo fmt + run: cargo fmt --all --check + + - name: Run cargo clippy + run: cargo clippy --all-targets + env: + PWD: ${{ github.workspace }} # without it ci can't see env!("PWD") cross-testing: strategy: @@ -33,19 +38,33 @@ jobs: runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - with: - toolchain: ${{ matrix.rust }} + - uses: actions/checkout@v4 - - run: cargo build --verbose - - run: cargo test --verbose + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + + - name: Build Floresta + run: cargo build --verbose + + - name: Run tests + run: cargo test --verbose + env: + PWD: ${{ github.workspace }} # without it ci can't see env!("PWD") build-docker: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: build the docker image - run: docker build -t dlsz/floresta:latest . + - uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Cache Docker layers + uses: actions/cache@v4 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-docker-${{ hashFiles('Dockerfile') }} + - name: Build Docker image + run: | + docker buildx build --cache-to=type=local,dest=/tmp/.buildx-cache --cache-from=type=local,src=/tmp/.buildx-cache -t dlsz/floresta:latest . From 9c3f8e9d56fe20b83cdc255bcde339ae26c29147 Mon Sep 17 00:00:00 2001 From: Guilherme Pereira Date: Fri, 4 Oct 2024 19:33:30 +0100 Subject: [PATCH 2/2] Remove swatinem from cross-testing job --- .github/workflows/rust.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c593c2127..6e9cde3d0 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -41,7 +41,15 @@ jobs: - uses: actions/checkout@v4 - name: Cache Rust - uses: Swatinem/rust-cache@v2 + uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Build Floresta run: cargo build --verbose