diff --git a/.github/workflows/go-test-monorepo.yml b/.github/workflows/go-test-monorepo.yml index b318530..38f7262 100644 --- a/.github/workflows/go-test-monorepo.yml +++ b/.github/workflows/go-test-monorepo.yml @@ -11,6 +11,18 @@ on: description: extra flags to add to go test type: string required: false + matrix: + description: | + Optional JSON string to define the test matrix, using keys: "os" and "go". + + By default tests run a 6-way matrix running on os (linux,windows,macos) + for the 2 latest go releases (stable, oldstable). + + The default matrix used is: + {"os":["ubuntu-latest","macos-latest","windows-latest"],"go": ["oldstable","stable"]} + + type: string + required: false defaults: run: @@ -27,6 +39,7 @@ jobs: module-names: ${{ steps.detect-monorepo.outputs.names }} coverpkg: ${{ steps.prepare-tests.outputs.coverpkg }} all-modules: ${{ steps.prepare-tests.outputs.all-modules }} + test-matrix: ${{ steps.test-matrix.outputs.test-matrix }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -88,15 +101,23 @@ jobs: # golangci-lint run --new-from-rev origin/master # popd # done < <(echo ${{ steps.detect-monorepo.outputs.bash-paths }}) + - + name: Test matrix + id: test-matrix + env: + MATRIX: | + ${{ inputs.test-matrix || '{"os":["ubuntu-latest","macos-latest","windows-latest"],"go": ["oldstable","stable"]}' }} + run: | + echo "test-matrix<> "${GITHUB_OUTPUT}" + printenv MATRIX >> "${GITHUB_OUTPUT}" + echo "EOF" >> "${GITHUB_OUTPUT}" test: name: Unit tests mono-repo needs: [ lint ] runs-on: ${{ matrix.os }} strategy: - matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - go: ['oldstable', 'stable' ] + matrix: ${{ fromJSON(needs.lint.outputs.test-matrix) }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 diff --git a/.github/workflows/go-test.yml b/.github/workflows/go-test.yml index 9de258d..de37d6d 100644 --- a/.github/workflows/go-test.yml +++ b/.github/workflows/go-test.yml @@ -11,6 +11,18 @@ on: description: extra flags to add to go test type: string required: false + matrix: + description: | + Optional JSON string to define the test matrix, using keys: "os" and "go". + + By default tests run a 6-way matrix running on os (linux,windows,macos) + for the 2 latest go releases (stable, oldstable). + + The default matrix used is: + {"os":["ubuntu-latest","macos-latest","windows-latest"],"go": ["oldstable","stable"]} + + type: string + required: false defaults: run: @@ -20,6 +32,8 @@ jobs: lint: name: Lint runs-on: ubuntu-latest + outputs: + test-matrix: ${{ steps.test-matrix.outputs.test-matrix }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 @@ -36,6 +50,16 @@ jobs: version: latest only-new-issues: true skip-cache: true + - + name: Test matrix + id: test-matrix + env: + MATRIX: | + ${{ inputs.test-matrix || '{"os":["ubuntu-latest","macos-latest","windows-latest"],"go": ["oldstable","stable"]}' }} + run: | + echo "test-matrix<> "${GITHUB_OUTPUT}" + printenv MATRIX >> "${GITHUB_OUTPUT}" + echo "EOF" >> "${GITHUB_OUTPUT}" test: name: Unit tests @@ -43,9 +67,7 @@ jobs: needs: [lint] strategy: - matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] - go: ['oldstable', 'stable' ] + matrix: ${{ fromJSON(needs.lint.outputs.test-matrix) }} steps: - diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 0000000..2099874 --- /dev/null +++ b/go.work.sum @@ -0,0 +1 @@ +github.com/go-openapi/testify/v2 v2.4.1/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= diff --git a/sample-monorepo/go.mod b/sample-monorepo/go.mod index 3b242f2..43790d9 100644 --- a/sample-monorepo/go.mod +++ b/sample-monorepo/go.mod @@ -2,4 +2,4 @@ module github.com/go-openapi/ci-workflows/sample-monorepo go 1.25.0 -require github.com/go-openapi/testify/v2 v2.4.1 +require github.com/go-openapi/testify/v2 v2.4.2 diff --git a/sample-monorepo/go.sum b/sample-monorepo/go.sum index 2cd1d1b..d679ea5 100644 --- a/sample-monorepo/go.sum +++ b/sample-monorepo/go.sum @@ -1 +1,2 @@ -github.com/go-openapi/testify/v2 v2.4.1 h1:zB34HDKj4tHwyUQHrUkpV0Q0iXQ6dUCOQtIqn8hE6Iw= +github.com/go-openapi/testify/v2 v2.4.2 h1:tiByHpvE9uHrrKjOszax7ZvKB7QOgizBWGBLuq0ePx4= +github.com/go-openapi/testify/v2 v2.4.2/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw=