Skip to content

Commit

Permalink
chore: trigger CI by labels only
Browse files Browse the repository at this point in the history
A new action helps by assigning labels based on the changed files.
A new set of labels makes it easy to distinguish which unit tests should be run.
We also set the trigger to only one target (the one coresponding to label changes), so that
no CI run is double triggered and nothing needs to be aborted.
  • Loading branch information
DanielMSchmidt committed Nov 22, 2022
1 parent 5a82ec1 commit 750d8c1
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 176 deletions.
55 changes: 55 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ci/run-unit/@cdktf/api-core:
# The workflow used
- ".github/workflows/unit.yml"
# All packages under test
- "packages/@cdktf/api-core/**"
# All scripts we use
- "tools/align-version.sh"

ci/run-unit/@cdktf/commons:
# The workflow used
- ".github/workflows/unit.yml"
# All packages under test
- "packages/@cdktf/commons/**"
# All scripts we use
- "tools/align-version.sh"

ci/run-unit/@cdktf/hcl2cdk:
# The workflow used
- ".github/workflows/unit.yml"
# All packages under test
- "packages/@cdktf/hcl2cdk/**"
# All scripts we use
- "tools/align-version.sh"

ci/run-unit/@cdktf/hcl2json:
# The workflow used
- ".github/workflows/unit.yml"
# All packages under test
- "packages/@cdktf/hcl2json/**"
# All scripts we use
- "tools/align-version.sh"

ci/run-unit/@cdktf/provider-generator:
# The workflow used
- ".github/workflows/unit.yml"
# All packages under test
- "packages/@cdktf/provider-generator/**"
# All scripts we use
- "tools/align-version.sh"

ci/run-unit/cdktf-cli:
# The workflow used
- ".github/workflows/unit.yml"
# All packages under test
- "packages/cdktf-cli/**"
# All scripts we use
- "tools/align-version.sh"

ci/run-unit/cdktf:
# The workflow used
- ".github/workflows/unit.yml"
# All packages under test
- "packages/cdktf/**"
# All scripts we use
- "tools/align-version.sh"
3 changes: 1 addition & 2 deletions .github/workflows/examples-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Examples - PR
on:
pull_request: {}
pull_request_target:
types:
- opened
Expand All @@ -11,7 +10,7 @@ on:

jobs:
examples:
if: contains(github.event.pull_request.labels.*.name, 'ci/run-examples') || contains(github.event.pull_request.labels.*.name, 'ci/run-all')
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-examples') || contains(github.event.pull_request.labels.*.name, 'ci/run-all') }}
uses: ./.github/workflows/examples.yml
with:
concurrency_group_prefix: pr
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/integration-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Integration Tests - PR
on:
pull_request: {}
pull_request_target:
types:
- opened
Expand All @@ -11,7 +10,7 @@ on:

jobs:
integration_test:
if: contains(github.event.pull_request.labels.*.name, 'ci/run-integration') || contains(github.event.pull_request.labels.*.name, 'ci/run-all')
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-integration') || contains(github.event.pull_request.labels.*.name, 'ci/run-all') }}
uses: ./.github/workflows/integration.yml
with:
concurrency_group_prefix: pr
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/pr-size.yml → .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
name: PR Size label

name: "Pull Request Labeler"
on: [pull_request]

jobs:
labeler:
pr_ci_trigger:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
# The config file lives under .github/labeler.yml
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: false # If set to true we could not easily overwrite it individually

pr_size:
runs-on: ubuntu-latest
name: Label the PR size
steps:
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/unit-@cdktf-api-core.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/unit-@cdktf-commons.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/unit-@cdktf-hcl2cdk.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/unit-@cdktf-hcl2json.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/unit-@cdktf-provider-generator.yml

This file was deleted.

99 changes: 98 additions & 1 deletion .github/workflows/unit-all.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Unit Tests - PR
on:
pull_request: {}
pull_request_target:
types:
- opened
- edited
- synchronize
- labeled
- reopened

jobs:
all_unit_tests:
Expand All @@ -25,3 +31,94 @@ jobs:
package: ${{ matrix.package }}
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit

cdktf_api_core:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-unit/@cdktf/api-core') }}
uses: ./.github/workflows/unit.yml
strategy:
fail-fast: false
matrix:
terraform_version: ["1.2.8"]
with:
concurrency_group_prefix: pr-cdktf-api-core
package: "@cdktf/api-core"
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit

cdktf_commons:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-unit/@cdktf/commons') }}
uses: ./.github/workflows/unit.yml
strategy:
fail-fast: false
matrix:
terraform_version: ["1.2.8"]
with:
concurrency_group_prefix: pr-cdktf-commons
package: "@cdktf/commons"
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit

cdktf_hcl2cdk:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-unit/@cdktf/hcl2cdk') }}
uses: ./.github/workflows/unit.yml
strategy:
fail-fast: false
matrix:
terraform_version: ["1.2.8"]
with:
concurrency_group_prefix: pr-cdktf-hcl2cdk
package: "@cdktf/hcl2cdk"
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit

cdktf_hcl2json:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-unit/@cdktf/hcl2json') }}
uses: ./.github/workflows/unit.yml
strategy:
fail-fast: false
matrix:
terraform_version: ["1.2.8"]
with:
concurrency_group_prefix: pr-cdktf-hcl2json
package: "@cdktf/hcl2json"
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit

cdktf_provider_generator:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-unit/@cdktf/provider-generator') }}
uses: ./.github/workflows/unit.yml
strategy:
fail-fast: false
matrix:
terraform_version: ["1.2.8"]
with:
concurrency_group_prefix: pr-cdktf-provider-generator
package: "@cdktf/provider-generator"
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit

cdktf_cli:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-unit/cdktf-cli') }}
uses: ./.github/workflows/unit.yml
strategy:
fail-fast: false
matrix:
terraform_version: ["1.2.8"]
with:
concurrency_group_prefix: pr-cdktf-cli
package: "cdktf-cli"
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit

cdktf:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci/run-unit/cdktf') }}
uses: ./.github/workflows/unit.yml
strategy:
fail-fast: false
matrix:
terraform_version: ["1.2.8"]
with:
concurrency_group_prefix: pr-cdktf
package: "cdktf"
terraform_version: ${{ matrix.terraform_version }}
secrets: inherit
24 changes: 0 additions & 24 deletions .github/workflows/unit-cdktf-cli.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/unit-cdktf.yml

This file was deleted.

0 comments on commit 750d8c1

Please sign in to comment.