Package on ubuntu:20.04 #21
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| branches: ["main"] | |
| push: | |
| branches: ["main"] | |
| tags: ["*"] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| compute-base-build-tag: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_tag: ${{ steps.out.outputs.tag }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Create Tag | |
| id: out | |
| run: echo "tag=${{ hashFiles('Dockerfile','rust-toolchain.toml') }}" >> "$GITHUB_OUTPUT" | |
| build-base: | |
| needs: compute-base-build-tag | |
| runs-on: ubuntu-latest | |
| env: | |
| CACHE_HIT: false | |
| IMAGE: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Pull Cached base Image | |
| run: | | |
| if docker manifest inspect "$IMAGE" > /dev/null 2>&1; then | |
| echo "CACHE_HIT=true" >> $GITHUB_ENV | |
| else | |
| echo "CACHE_HIT=false" >> $GITHUB_ENV | |
| fi | |
| - name: Set up Docker Buildx | |
| if: env.CACHE_HIT == 'false' | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4 | |
| - name: Build and Push base Image (if not cached) | |
| if: env.CACHE_HIT == 'false' | |
| uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| target: base | |
| push: true | |
| tags: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }} | |
| fmt: | |
| needs: [compute-base-build-tag, build-base] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-fmt | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Check formatting | |
| run: cargo fmt -- --check | |
| clippy: | |
| needs: [compute-base-build-tag, build-base] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-clippy | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Cache Cargo Target Directory | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 | |
| with: | |
| path: target | |
| key: clippy-base-${{ needs.compute-base-build-tag.outputs.image_tag }}-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| clippy-base-${{ needs.compute-base-build-tag.outputs.image_tag }}- | |
| - name: Clippy | |
| run: cargo clippy --all-targets -- -Dclippy::all -D warnings | |
| tests: | |
| needs: [compute-base-build-tag, build-base] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ghcr.io/${{ github.repository }}/base:${{ needs.compute-base-build-tag.outputs.image_tag }} | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-tests | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Cache Cargo Target Directory | |
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5 | |
| with: | |
| path: target | |
| key: tests-base-${{ needs.compute-base-build-tag.outputs.image_tag }}-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| tests-base-${{ needs.compute-base-build-tag.outputs.image_tag }}- | |
| - name: Run tests | |
| run: cargo test | |
| build-package: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [compute-base-build-tag, fmt, clippy, tests] | |
| runs-on: ubuntu-latest | |
| container: | |
| image: ubuntu:20.04 | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-build-package | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Rust install | |
| uses: actions-rust-lang/setup-rust-toolchain@150fca883cd4034361b621bd4e6a9d34e5143606 # v1 | |
| - name: Install Protoc | |
| uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Debian packaging | |
| env: | |
| PACKAGECLOUD_API_KEY: ${{ secrets.PACKAGECLOUD_API_KEY }} | |
| run: | | |
| chmod +x ./.github/scripts/make_debian.sh | |
| ./.github/scripts/make_debian.sh | |
| build-image: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| needs: [fmt, clippy, tests] | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-build-image | |
| cancel-in-progress: true | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@b45d80f862d83dbcd57f89517bcf500b2ab88fb2 # v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4 | |
| - name: Build and Push base Image | |
| uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7 | |
| with: | |
| context: . | |
| file: Dockerfile | |
| target: runner | |
| push: true | |
| tags: ghcr.io/${{ github.repository }}/multi_buy_service:${{ github.ref_name }} |