From e814cd6c2052779fbdb824af1786e79f723e4786 Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 8 Feb 2024 14:50:27 -0600 Subject: [PATCH] Use custom base image for CI --- .forgejo/workflows/check.yaml | 21 +----- .forgejo/workflows/publish.yaml | 130 ++++++++++++-------------------- 2 files changed, 53 insertions(+), 98 deletions(-) diff --git a/.forgejo/workflows/check.yaml b/.forgejo/workflows/check.yaml index dc00915..f1dc5cb 100644 --- a/.forgejo/workflows/check.yaml +++ b/.forgejo/workflows/check.yaml @@ -8,14 +8,11 @@ jobs: clippy: runs-on: docker container: - image: docker.io/node:20-bookworm + image: docker.io/asonix/actions-base-image:0.1 steps: - name: Checkout pict-rs uses: https://github.com/actions/checkout@v4 - - - name: Setup Rust - uses: https://git.asonix.dog/asonix/pict-rs/.forgejo/actions/prepare-rust@main - name: Clippy run: | @@ -25,20 +22,18 @@ jobs: tests: runs-on: docker container: - image: docker.io/node:20-bookworm + image: docker.io/asonix/actions-base-image:0.1 steps: - name: Checkout pict-rs uses: https://github.com/actions/checkout@v4 - - - name: Setup Rust - uses: https://git.asonix.dog/asonix/pict-rs/.forgejo/actions/prepare-rust@main - name: Test run: cargo test check: strategy: + fail-fast: false matrix: target: - x86_64-unknown-linux-musl @@ -46,19 +41,11 @@ jobs: - aarch64-unknown-linux-musl runs-on: docker container: - image: docker.io/node:20-bookworm + image: docker.io/asonix/actions-base-image:0.1 steps: - name: Checkout pict-rs uses: https://github.com/actions/checkout@v4 - - - name: Setup Rust - uses: https://git.asonix.dog/asonix/pict-rs/.forgejo/actions/prepare-rust@main - with: - targets: | - ["x86_64-unknown-linux-musl", - "armv7-unknown-linux-musleabihf", - "aarch64-unknown-linux-musl"] - name: Debug builds run: cargo zigbuild --target ${{ matrix.target }} diff --git a/.forgejo/workflows/publish.yaml b/.forgejo/workflows/publish.yaml index 7d2bca1..951154f 100644 --- a/.forgejo/workflows/publish.yaml +++ b/.forgejo/workflows/publish.yaml @@ -5,49 +5,43 @@ on: env: REGISTRY_IMAGE: asonix/pictrs - DOCKER_HOST: tcp://docker-in-docker:2375 jobs: - # clippy: - # runs-on: docker - # container: - # image: docker.io/node:20-bookworm - # steps: - # - - # name: Checkout pict-rs - # uses: https://github.com/actions/checkout@v4 - # - - # name: Setup Rust - # uses: https://git.asonix.dog/asonix/pict-rs/.forgejo/actions/prepare-rust@main - # - - # name: Clippy - # run: | - # cargo clippy --no-default-features -- -D warnings - # cargo clippy --no-default-features --features io-uring -- -D warnings + clippy: + runs-on: base-image + container: + image: docker.io/asonix/actions-base-image:0.1 + steps: + - + name: Checkout pict-rs + uses: https://github.com/actions/checkout@v4 + - + name: Clippy + run: | + cargo clippy --no-default-features -- -D warnings + cargo clippy --no-default-features --features io-uring -- -D warnings - # tests: - # runs-on: docker - # container: - # image: docker.io/node:20-bookworm - # steps: - # - - # name: Checkout pict-rs - # uses: https://github.com/actions/checkout@v4 - # - - # name: Setup Rust - # uses: https://git.asonix.dog/asonix/pict-rs/.forgejo/actions/prepare-rust@main - # - - # name: Test - # run: cargo test - - build: - # needs: - # - clippy - # - tests + tests: runs-on: docker container: - image: docker.io/node:20-bookworm + image: docker.io/asonix/actions-base-image:0.1 + steps: + - + name: Checkout pict-rs + uses: https://github.com/actions/checkout@v4 + - + name: Test + run: cargo test + + build: + needs: + - clippy + - tests + runs-on: docker + container: + image: docker.io/asonix/actions-base-image:0.1 strategy: + fail-fast: false matrix: info: - target: x86_64-unknown-linux-musl @@ -63,20 +57,6 @@ jobs: - name: Checkout pict-rs uses: https://github.com/actions/checkout@v4 - - - name: Install Docker - run: | - apt-get update - apt-get install -y ca-certificates curl jq - install -m 0755 -d /etc/apt/keyrings - curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc - chmod a+r /etc/apt/keyrings/docker.asc - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ - $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ - tee /etc/apt/sources.list.d/docker.list > /dev/null - apt-get update - apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - name: Prepare Platform run: | @@ -89,6 +69,15 @@ jobs: uses: https://github.com/docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} + flavor: | + latest=false + suffix=-${{ matrix.info.artifact }} + tags: | + type=raw,value=latest,enable={{ is_default_branch }} + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=ref,event=branch - name: Set up QEMU uses: https://github.com/docker/setup-qemu-action@v3 @@ -101,14 +90,6 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Setup Rust - uses: https://git.asonix.dog/asonix/pict-rs/.forgejo/actions/prepare-rust@main - with: - targets: | - ["x86_64-unknown-linux-musl", - "armv7-unknown-linux-musleabihf", - "aarch64-unknown-linux-musl"] - name: Compile pict-rs run: cargo zigbuild --target ${{ matrix.info.target }} --release @@ -132,10 +113,10 @@ jobs: uses: docker/build-push-action@v5 with: context: ./docker/forgejo - # file: ./docker/forgejo/Dockerfile platforms: ${{ matrix.info.platform }} + tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},name-canonical=true,push=true - name: Export digest run: | @@ -156,23 +137,9 @@ jobs: publish-docker: runs-on: docker container: - image: docker.io/node:20-bookworm + image: docker.io/asonix/actions-base-image:0.1 needs: [build] steps: - - - name: Install Docker - run: | - apt-get update - apt-get install -y ca-certificates curl jq - install -m 0755 -d /etc/apt/keyrings - curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc - chmod a+r /etc/apt/keyrings/docker.asc - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \ - $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ - tee /etc/apt/sources.list.d/docker.list > /dev/null - apt-get update - apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin - name: Download digests uses: https://github.com/actions/download-artifact@v3 @@ -196,10 +163,14 @@ jobs: uses: https://github.com/docker/metadata-action@v5 with: images: ${{ env.REGISTRY_IMAGE }} + flavor: | + latest=false tags: | + type=raw,value=latest,enable={{ is_default_branch }} type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} + type=ref,event=branch - name: Create manifest list and push working-directory: /tmp/digests @@ -218,7 +189,7 @@ jobs: needs: [build] runs-on: docker container: - image: node:20-bookworm + image: docker.io/asonix/actions-base-image:0.1 steps: - uses: https://github.com/actions/download-artifact@v3 with: @@ -236,14 +207,11 @@ jobs: needs: [build] runs-on: docker container: - image: node:20-bookworm + image: docker.io/asonix/actions-base-image:0.1 steps: - name: Checkout pict-rs uses: https://github.com/actions/checkout@v4 - - - name: Setup Rust - uses: https://git.asonix.dog/asonix/pict-rs/.forgejo/actions/prepare-rust@main - name: Publish Crate run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}