From 0e2f0381d020e445394d143f338b7a59a7d46151 Mon Sep 17 00:00:00 2001 From: Geza Lore Date: Wed, 17 Sep 2025 21:41:29 +0200 Subject: [PATCH] CI: Improve and cleanup (#6448) Chores: - Remove ci-ccache-maint. This has never been useful and is just cruft. - Remove then unused CI_COMMIT - Change job names so they come out nicer in the web views - Make os-name input to reusable-build always explicit Improvements: - Have at most build-test job in progress per branch - Cancel in-progress build-test jobs on PRs - In forks (that is, not on 'verilator/verilator'), cancel any in-progress build-test jobs on push to the branch --- .github/workflows/build-test.yml | 32 +++++++++++++++----------- .github/workflows/coverage.yml | 1 - .github/workflows/format.yml | 5 +--- .github/workflows/reusable-build.yml | 10 ++++---- .github/workflows/reusable-lint-py.yml | 1 - .github/workflows/reusable-test.yml | 3 +-- .github/workflows/rtlmeter.yml | 3 ++- ci/ci-ccache-maint.bash | 30 ------------------------ ci/ci-install.bash | 2 +- 9 files changed, 27 insertions(+), 60 deletions(-) delete mode 100755 ci/ci-ccache-maint.bash diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 28f98acd0..6a11395f4 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -22,16 +22,18 @@ defaults: working-directory: repo concurrency: - group: ${{ github.workflow }}-${{ github.actor }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} - cancel-in-progress: true + # At most 1 job per branch. Auto cancel on pull requests and on all forks + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'verilator/verilator' }} jobs: build-2404-gcc: - name: Build-Ubuntu + name: Build | ${{ matrix.os }} | ${{ matrix.cc }}${{ matrix.asan && ' | asan' || '' }} uses: ./.github/workflows/reusable-build.yml with: os: ${{ matrix.os }} + os-name: linux cc: ${{ matrix.cc }} asan: ${{ matrix.asan }} strategy: @@ -41,10 +43,11 @@ jobs: - {os: ubuntu-24.04, cc: gcc, asan: 0} build-2404-clang: - name: Build-Ubuntu + name: Build | ${{ matrix.os }} | ${{ matrix.cc }}${{ matrix.asan && ' | asan' || '' }} uses: ./.github/workflows/reusable-build.yml with: os: ${{ matrix.os }} + os-name: linux cc: ${{ matrix.cc }} asan: ${{ matrix.asan }} strategy: @@ -54,10 +57,11 @@ jobs: - {os: ubuntu-24.04, cc: clang, asan: 1} build-2204-gcc: - name: Build-Ubuntu + name: Build | ${{ matrix.os }} | ${{ matrix.cc }}${{ matrix.asan && ' | asan' || '' }} uses: ./.github/workflows/reusable-build.yml with: os: ${{ matrix.os }} + os-name: linux cc: ${{ matrix.cc }} asan: ${{ matrix.asan }} strategy: @@ -67,10 +71,11 @@ jobs: - {os: ubuntu-22.04, cc: gcc, asan: 0} build-2204-clang: - name: Build-Ubuntu + name: Build | ${{ matrix.os }} | ${{ matrix.cc }}${{ matrix.asan && ' | asan' || '' }} uses: ./.github/workflows/reusable-build.yml with: os: ${{ matrix.os }} + os-name: linux cc: ${{ matrix.cc }} asan: ${{ matrix.asan }} strategy: @@ -80,7 +85,7 @@ jobs: - {os: ubuntu-22.04, cc: clang, asan: 0} build-osx-gcc: - name: Build-OSX + name: Build | ${{ matrix.os }} | ${{ matrix.cc }}${{ matrix.asan && ' | asan' || '' }} uses: ./.github/workflows/reusable-build.yml with: os: ${{ matrix.os }} @@ -94,7 +99,7 @@ jobs: - {os: macos-15, cc: gcc, asan: 0} build-osx-clang: - name: Build-OSX + name: Build | ${{ matrix.os }} | ${{ matrix.cc }}${{ matrix.asan && ' | asan' || '' }} uses: ./.github/workflows/reusable-build.yml with: os: ${{ matrix.os }} @@ -108,7 +113,7 @@ jobs: - {os: macos-15, cc: clang, asan: 0} build-windows: - name: Build-Windows + name: Build | ${{ matrix.os }} | ${{ matrix.cc }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -117,7 +122,6 @@ jobs: - {os: windows-2025, cc: msvc} env: CI_OS_NAME: win - CI_COMMIT: ${{ github.sha }} CCACHE_COMPRESS: 1 CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_LIMIT_MULTIPLE: 0.95 @@ -145,7 +149,7 @@ jobs: name: verilator-win.zip test-2404-gcc: - name: Test | ${{ matrix.os }} | ${{ matrix.cc }} + name: Test | ${{ matrix.os }} | ${{ matrix.cc }} | ${{ matrix.reloc && 'reloc | ' || '' }} ${{ matrix.suite }} needs: build-2404-gcc uses: ./.github/workflows/reusable-test.yml with: @@ -167,7 +171,7 @@ jobs: - {os: ubuntu-24.04, cc: gcc, reloc: 0, suite: vltmt-2} test-2404-clang: - name: Test | ${{ matrix.os }} | ${{ matrix.cc }} + name: Test | ${{ matrix.os }} | ${{ matrix.cc }} | ${{ matrix.reloc && 'reloc | ' || '' }} ${{ matrix.suite }} needs: build-2404-clang uses: ./.github/workflows/reusable-test.yml with: @@ -189,7 +193,7 @@ jobs: - {os: ubuntu-24.04, cc: clang, reloc: 0, suite: vltmt-2} test-2204-gcc: - name: Test | ${{ matrix.os }} | ${{ matrix.cc }} + name: Test | ${{ matrix.os }} | ${{ matrix.cc }} | ${{ matrix.reloc && 'reloc | ' || '' }} ${{ matrix.suite }} needs: build-2204-gcc uses: ./.github/workflows/reusable-test.yml with: @@ -211,7 +215,7 @@ jobs: - {os: ubuntu-22.04, cc: gcc, reloc: 0, suite: vltmt-2} test-2204-clang: - name: Test | ${{ matrix.os }} | ${{ matrix.cc }} + name: Test | ${{ matrix.os }} | ${{ matrix.cc }} | ${{ matrix.reloc && 'reloc | ' || '' }} ${{ matrix.suite }} needs: build-2204-clang uses: ./.github/workflows/reusable-test.yml with: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 0f3e0b5b0..d213f05a4 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -14,7 +14,6 @@ permissions: env: CI_OS_NAME: linux - CI_COMMIT: ${{ github.sha }} COVERAGE: 1 VERILATOR_ARCHIVE: verilator-coverage-${{ github.sha }}.tar.gz diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 80f0b1b54..09677558c 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -7,10 +7,7 @@ on: push: branches-ignore: - 'dependabot/**' # Avoid duplicates: only run the PR, not the push - pull_request_target: - workflow_dispatch: -permissions: - contents: write + jobs: format: runs-on: ubuntu-24.04 diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index a7018dc35..9fda586cb 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -10,20 +10,18 @@ on: os: # e.g. ubuntu-24.04 required: true type: string - cc: # gcc or clang + cc: # 'clang' or 'gcc' required: true type: string - os-name: - required: false + os-name: # 'linux' or 'osx' + required: true type: string - default: linux asan: required: true type: number env: CI_OS_NAME: ${{ inputs.os-name }} - CI_COMMIT: ${{ github.sha }} CCACHE_COMPRESS: 1 CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_LIMIT_MULTIPLE: 0.95 @@ -39,7 +37,7 @@ jobs: build: runs-on: ${{ inputs.os }} - name: Sub-build | ${{ inputs.os }} | ${{ inputs.cc }} + name: Build env: CI_ASAN: ${{ inputs.asan }} CI_BUILD_STAGE_NAME: build diff --git a/.github/workflows/reusable-lint-py.yml b/.github/workflows/reusable-lint-py.yml index a991dc606..511e6cf69 100644 --- a/.github/workflows/reusable-lint-py.yml +++ b/.github/workflows/reusable-lint-py.yml @@ -9,7 +9,6 @@ on: env: CI_OS_NAME: linux - CI_COMMIT: ${{ github.sha }} CI_BUILD_STAGE_NAME: build CI_RUNS_ON: ubuntu-22.04 CCACHE_COMPRESS: 1 diff --git a/.github/workflows/reusable-test.yml b/.github/workflows/reusable-test.yml index 4795bc605..548bfab20 100644 --- a/.github/workflows/reusable-test.yml +++ b/.github/workflows/reusable-test.yml @@ -22,7 +22,6 @@ on: env: CI_OS_NAME: linux - CI_COMMIT: ${{ github.sha }} CCACHE_COMPRESS: 1 CCACHE_DIR: ${{ github.workspace }}/.ccache CCACHE_LIMIT_MULTIPLE: 0.95 @@ -38,7 +37,7 @@ jobs: test: runs-on: ${{ inputs.os }} - name: Sub-test | ${{ inputs.os }} | ${{ inputs.cc }} | ${{inputs.reloc && 'reloc | ' || '' }} ${{ inputs.suite }} + name: Test env: CI_BUILD_STAGE_NAME: test CI_RUNS_ON: ${{ inputs.os }} diff --git a/.github/workflows/rtlmeter.yml b/.github/workflows/rtlmeter.yml index e2541550c..c0913b21a 100644 --- a/.github/workflows/rtlmeter.yml +++ b/.github/workflows/rtlmeter.yml @@ -20,7 +20,8 @@ defaults: shell: bash concurrency: - group: ${{ github.ref }} + # At most 1 job per branch. Auto cancel all but scheduled jobs + group: ${{ github.worfklow }}-${{ github.ref }} cancel-in-progress: ${{ github.event_name != 'schedule' }} jobs: diff --git a/ci/ci-ccache-maint.bash b/ci/ci-ccache-maint.bash deleted file mode 100755 index ee0195a8d..000000000 --- a/ci/ci-ccache-maint.bash +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -# DESCRIPTION: Verilator: CI ccache maintenance -# -# Copyright 2020 by Geza Lore. This program is free software; you -# can redistribute it and/or modify it under the terms of either the GNU -# Lesser General Public License Version 3 or the Perl Artistic License -# Version 2.0. -# -# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 - -################################################################################ -# This script is run in 'before_script', once ccache has been set up. -################################################################################ - -set -e -set -x - -# Show version -ccache --version - -# Flush ccache if requested in commit message -COMMIT="${CI_PULL_REQUEST_SHA:-$CI_COMMIT}" -if git log --format=%B -n 1 "$COMMIT" | grep -q -i '\[CI\s\+ccache\s\+clear\]'; then - echo "Flushing ccache due to commit message" - ccache -C -fi - -# Dump stats, then zero stats -# 22.04: ccache -s -v -z -ccache -s -z diff --git a/ci/ci-install.bash b/ci/ci-install.bash index 2f54e3b3c..4f349cc02 100755 --- a/ci/ci-install.bash +++ b/ci/ci-install.bash @@ -85,7 +85,7 @@ if [ "$CI_BUILD_STAGE_NAME" = "build" ]; then fi if [ -n "$CCACHE_DIR" ]; then - mkdir -p "$CCACHE_DIR" && ./ci/ci-ccache-maint.bash + mkdir -p "$CCACHE_DIR" fi elif [ "$CI_BUILD_STAGE_NAME" = "test" ]; then ##############################################################################