From 3ce30482a3765072701b0dfdcad9fdfd9e50905b Mon Sep 17 00:00:00 2001 From: Tim Fischer Date: Tue, 10 Sep 2024 09:27:23 +0200 Subject: [PATCH] ci: Use `build-docker` workflow as dependency for other workflows --- .github/workflows/build-docker.yml | 42 ++++++++++++++++++++++ .github/workflows/ci.yml | 58 +++++------------------------- .github/workflows/lint.yml | 41 ++++----------------- 3 files changed, 57 insertions(+), 84 deletions(-) create mode 100644 .github/workflows/build-docker.yml diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml new file mode 100644 index 000000000..6ece706ac --- /dev/null +++ b/.github/workflows/build-docker.yml @@ -0,0 +1,42 @@ +# Copyright 2020 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +name: build-docker +on: [push, pull_request] + +jobs: + + ########################## + # Build Docker Container # + ########################## + + build-docker: + name: Deploy Docker image + runs-on: ubuntu-22.04 + # Skip pull requests from internal contributors. + if: > + github.event_name != 'pull_request' || + github.event.pull_request.head.repo.full_name != github.repository + steps: + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + docker-images: false + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - name: GHCR Log-in + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + cache-from: type=gha + cache-to: type=gha,mode=max` + file: util/container/Dockerfile + push: true + tags: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07a0be0d7..2b4d3ffde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,43 +4,13 @@ # Run functional regression checks name: ci -on: [push, pull_request] +on: + workflow_run: + workflows: [build-docker] + types: [completed] jobs: - ########################## - # Build Docker Container # - ########################## - - build-docker: - name: Deploy Docker image - runs-on: ubuntu-22.04 - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository - steps: - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - docker-images: false - - uses: actions/checkout@v4 - - uses: docker/setup-buildx-action@v3 - - name: GHCR Log-in - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - cache-from: type=gha - cache-to: type=gha,mode=max` - file: util/container/Dockerfile - push: true - tags: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} - ######## # Docs # ######## @@ -48,12 +18,9 @@ jobs: docs: name: Build documentation runs-on: ubuntu-22.04 - needs: build-docker - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository container: image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v2 - name: Build docs @@ -66,12 +33,9 @@ jobs: pytest: name: Python unit tests runs-on: ubuntu-22.04 - needs: build-docker - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository container: image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v2 - name: Run pytest @@ -84,12 +48,9 @@ jobs: sw-snitch-cluster-vlt: name: Simulate SW on Snitch Cluster w/ Verilator runs-on: ubuntu-22.04 - needs: build-docker - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository container: image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v2 with: @@ -135,12 +96,9 @@ jobs: sw-snitch-cluster-banshee: name: Simulate SW on Snitch Cluster w/ Banshee runs-on: ubuntu-22.04 - needs: build-docker - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository container: image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f36145f0b..67518f30c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,7 +4,10 @@ # Run all lint checks name: lint -on: [push, pull_request] +on: + workflow_run: + workflows: [build-docker] + types: [completed] jobs: @@ -14,9 +17,6 @@ jobs: verible-lint: name: Lint Verilog sources runs-on: ubuntu-latest - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository steps: - uses: actions/checkout@v3 - uses: chipsalliance/verible-linter-action@main @@ -35,9 +35,6 @@ jobs: bender-vendor-up-to-date: name: Check bender vendor up-to-date runs-on: ubuntu-latest - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository steps: - name: Check bender vendor up-to-date uses: pulp-platform/pulp-actions/bender-vendor-up-to-date@v2.1.0 @@ -48,22 +45,13 @@ jobs: sources-up-to-date: name: Check Sources Up-to-Date runs-on: ubuntu-22.04 - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository + container: + image: ghcr.io/pulp-platform/snitch_cluster:${{ github.ref_name }} + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - uses: actions/checkout@v4 with: submodules: true - - name: Install bender - uses: pulp-platform/pulp-actions/bender-install@v2 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - cache: 'pip' - - name: Install pip dependencies - run: | - pip install . - name: Generate opcodes run: | ./util/generate-opcodes.sh @@ -82,9 +70,6 @@ jobs: license-lint: name: Check License headers runs-on: ubuntu-latest - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository steps: - name: Check License uses: pulp-platform/pulp-actions/lint-license@v2.1.0 @@ -108,9 +93,6 @@ jobs: yaml-lint: name: Lint YAML Sources runs-on: ubuntu-latest - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository steps: - uses: actions/checkout@v3 - name: yaml-lint @@ -123,9 +105,6 @@ jobs: ######################## python-lint: runs-on: ubuntu-latest - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository name: Lint Python Sources steps: - name: Check out source repository @@ -147,9 +126,6 @@ jobs: clangfmt: name: Lint C/C++ Sources runs-on: ubuntu-latest - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository steps: - uses: actions/checkout@v3 - uses: DoozyX/clang-format-lint-action@v0.18.1 @@ -163,9 +139,6 @@ jobs: editorconfig-lint: name: Lint Editorconfig runs-on: ubuntu-latest - if: > - github.event_name != 'pull_request' || - github.event.pull_request.head.repo.full_name != github.repository steps: - uses: actions/checkout@v3 - uses: editorconfig-checker/action-editorconfig-checker@main