Skip to content

Reduce CI workflow duplication with a reusable composite action #5648

@Devansh-567

Description

@Devansh-567

Summary

Several CI workflows contain nearly identical setup steps for building p4c:

  • Checkout repository with recursive submodules
  • Configure ccache
  • Run tools/ci-build.sh

This pattern appears in multiple workflows, including:

  • ci-lint.yaml
  • ci-p4tools.yml
  • ci-ptf.yml
  • ci-static-build-test.yml
  • ci-validation-nightly.yml
  • ci-test-debian.yml
  • and others

Proposal

Introduce a reusable composite action under:

.github/actions/setup-p4c-build/action.yml

to encapsulate common setup logic.

Example:

name: Setup p4c build environment

inputs:
  ccache-key:
    required: true

runs:
  using: composite
  steps:
    - uses: actions/checkout@v6
      with:
        submodules: recursive

    - uses: hendrikmuhs/ccache-action@v1
      with:
        key: ${{ inputs.ccache-key }}-${{ runner.os }}
        max-size: 1000M

Workflows would then invoke the composite action and keep only workflow-specific build and test steps.

Benefits

  • Reduces duplicated CI configuration.
  • Makes future CI updates easier (e.g. cache configuration changes).
  • Lowers the risk of workflow drift between jobs.
  • Improves maintainability by centralizing common setup logic.

Expected Changes

  • Add .github/actions/setup-p4c-build/action.yml.
  • Migrate affected workflows to use the composite action.
  • Preserve existing workflow behavior and cache keys.
  • Reduce duplicated CI setup code across the repository.

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrastructureTopics related to code style and build and test infrastructure.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions