chore: run lint in a separate build before running the tests #7447
Workflow file for this run
This file contains 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: Main pipeline | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.sha }} | |
cancel-in-progress: true | |
jobs: | |
detect-modules: | |
runs-on: ubuntu-latest | |
outputs: | |
modules: ${{ steps.set-modified-modules.outputs.modules }} | |
modules_count: ${{ steps.set-modified-modules-count.outputs.modules_count }} | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4 | |
- id: changed-files | |
name: Get changed files | |
uses: tj-actions/changed-files@v45 | |
- id: set-modified-modules | |
name: Set all modified modules | |
env: | |
ALL_CHANGED_FILES: "${{ steps.changed-files.outputs.all_changed_files }}" | |
run: echo "modules=$(./scripts/changed-modules.sh)" >> $GITHUB_OUTPUT | |
- id: set-modified-modules-count | |
name: Set all modified modules count | |
run: echo "modules_count=$(echo ${{ toJSON(steps.set-modified-modules.outputs.modules) }} | jq '. | length')" >> $GITHUB_OUTPUT | |
- name: Print out the modules to be used | |
run: | | |
echo "${{ steps.set-modified-modules-count.outputs.modules_count }} modules in the build" | |
echo "${{ steps.set-modified-modules.outputs.modules }}" | |
test: | |
# only run if there are modules to test | |
if: ${{ needs.detect-modules.outputs.modules_count > 0 }} | |
needs: | |
- detect-modules | |
strategy: | |
matrix: | |
go-version: [1.22.x, 1.x] | |
module: ${{ fromJSON(needs.detect-modules.outputs.modules) }} | |
uses: ./.github/workflows/ci-test-go.yml | |
with: | |
go-version: ${{ matrix.go-version }} | |
fail-fast: true | |
platforms: ${{ matrix.module == 'modulegen' && '["ubuntu-latest", "macos-latest", "windows-latest"]' || '["ubuntu-latest"]' }} | |
project-directory: "${{ matrix.module }}" | |
rootless-docker: false | |
ryuk-disabled: false | |
# The job below is a copy of the job above, but with ryuk disabled. | |
# It's executed in the first stage to avoid concurrency issues. | |
test-reaper-off: | |
# the core module is identified by the empty string (the root path) | |
if: ${{ contains(fromJSON(needs.detect-modules.outputs.modules), '') }} | |
needs: | |
- detect-modules | |
name: "Test with reaper off" | |
strategy: | |
matrix: | |
go-version: [1.22.x, 1.x] | |
uses: ./.github/workflows/ci-test-go.yml | |
with: | |
go-version: ${{ matrix.go-version }} | |
fail-fast: false | |
platforms: '["ubuntu-latest"]' | |
project-directory: "." | |
rootless-docker: false | |
ryuk-disabled: true | |
# The job below is a copy of the job above, but with Docker rootless. | |
# It's executed in the first stage to avoid concurrency issues. | |
test-rootless-docker: | |
# the core module is identified by the empty string (the root path) | |
if: ${{ contains(fromJSON(needs.detect-modules.outputs.modules), '') }} | |
needs: | |
- detect-modules | |
name: "Test with Rootless Docker" | |
strategy: | |
matrix: | |
go-version: [1.22.x, 1.x] | |
uses: ./.github/workflows/ci-test-go.yml | |
with: | |
go-version: ${{ matrix.go-version }} | |
fail-fast: false | |
platforms: '["ubuntu-latest"]' | |
project-directory: "." | |
rootless-docker: true | |
ryuk-disabled: false | |
sonarcloud: | |
permissions: | |
contents: read # for actions/checkout to fetch code | |
pull-requests: read # for sonarsource/sonarcloud-github-action to determine which PR to decorate | |
if: ${{ github.ref_name == 'main' && github.repository_owner == 'testcontainers' && needs.detect-modules.outputs.modules_count > 0 }} | |
needs: | |
- detect-modules | |
- test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
# Disabling shallow clone is recommended for improving relevancy of reporting | |
fetch-depth: 0 | |
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 | |
with: | |
name: sonarcloud | |
- name: Analyze with SonarCloud | |
uses: sonarsource/sonarcloud-github-action@49e6cd3b187936a73b8280d59ffd9da69df63ec9 # v2.1.1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |