pulumi/.github/workflows/on-pr.yml

123 lines
3.8 KiB
YAML
Raw Permalink Normal View History

2022-09-02 05:40:13 +00:00
name: Pull Request
permissions:
# To create a draft release.
2022-09-02 05:40:13 +00:00
contents: write
# To comment on PRs.
2022-09-02 05:40:13 +00:00
pull-requests: write
# To sign artifacts.
id-token: write
2022-09-02 05:40:13 +00:00
on:
pull_request:
paths-ignore:
- "sdk/.version"
2022-09-02 05:40:13 +00:00
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
2022-09-02 05:40:13 +00:00
cancel-in-progress: true
# The jobs in this workflow are only run on branches. The `on-community-pr.yml` job provides
# commands for running workflows from forks.
2022-09-02 05:40:13 +00:00
jobs:
info:
name: info
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
2022-09-02 05:40:13 +00:00
uses: ./.github/workflows/ci-info.yml
permissions:
contents: read
with:
ref: ${{ github.head_ref }}
2022-09-02 05:40:13 +00:00
is-snapshot: true
secrets: inherit
# Determines which files have changed so we can avoid running expensive tests
ci: Don't run codegen tests for PRs We currently run all codegen tests in pkg/codegen/$lang for every PR. These tests take quite a while to run and lock up many GitHub workers for this entire duration. This change attempts to address this issue by running codegen tests only for those PRs that touch the codegen directories. The machinery to make this work is roughly as follows: - In the on-pr workflow, when we're figuring out what we're doing, we check if we've changed codegen files. We use [paths-filter] to do this. - We decide whether we want to run codegen tests based on those files, and pass that onto the test matrix generator. - The test matrix generator filters out these packages and their subpackages from the list of tests under consideration. - Everything else proceeds as normal. [paths-filter]: https://github.com/dorny/paths-filter Things to note: - The test-codegen input defaults to true. All other invocations will run with codegen tests so these will continue to run on merge. Only PRs (from on-pr.yml) set it to false. - Since the number of tests is remarkably smaller without these tests, we can significantly reduce the number of partitions we use for pkg/ unit tests. This should alleviate pressure on GitHub workers further. This is a pretty blunt approach to the problem. If we wanted to be more targeted, instead of filtering at the get-job-matrix.py level, we could instead set an environment variable and add t.Skips in {program,sdk,type}_driver if that environment variable is set. And we can still do that in the future if we decide that maintaining this list is too much. Resolves #12334
2023-03-02 22:33:45 +00:00
# if they're not necessary.
inspect:
name: Inspect changed files
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
ci: Don't run codegen tests for PRs We currently run all codegen tests in pkg/codegen/$lang for every PR. These tests take quite a while to run and lock up many GitHub workers for this entire duration. This change attempts to address this issue by running codegen tests only for those PRs that touch the codegen directories. The machinery to make this work is roughly as follows: - In the on-pr workflow, when we're figuring out what we're doing, we check if we've changed codegen files. We use [paths-filter] to do this. - We decide whether we want to run codegen tests based on those files, and pass that onto the test matrix generator. - The test matrix generator filters out these packages and their subpackages from the list of tests under consideration. - Everything else proceeds as normal. [paths-filter]: https://github.com/dorny/paths-filter Things to note: - The test-codegen input defaults to true. All other invocations will run with codegen tests so these will continue to run on merge. Only PRs (from on-pr.yml) set it to false. - Since the number of tests is remarkably smaller without these tests, we can significantly reduce the number of partitions we use for pkg/ unit tests. This should alleviate pressure on GitHub workers further. This is a pretty blunt approach to the problem. If we wanted to be more targeted, instead of filtering at the get-job-matrix.py level, we could instead set an environment variable and add t.Skips in {program,sdk,type}_driver if that environment variable is set. And we can still do that in the future if we decide that maintaining this list is too much. Resolves #12334
2023-03-02 22:33:45 +00:00
runs-on: ubuntu-latest
steps:
- uses: dorny/paths-filter@v3
ci: Don't run codegen tests for PRs We currently run all codegen tests in pkg/codegen/$lang for every PR. These tests take quite a while to run and lock up many GitHub workers for this entire duration. This change attempts to address this issue by running codegen tests only for those PRs that touch the codegen directories. The machinery to make this work is roughly as follows: - In the on-pr workflow, when we're figuring out what we're doing, we check if we've changed codegen files. We use [paths-filter] to do this. - We decide whether we want to run codegen tests based on those files, and pass that onto the test matrix generator. - The test matrix generator filters out these packages and their subpackages from the list of tests under consideration. - Everything else proceeds as normal. [paths-filter]: https://github.com/dorny/paths-filter Things to note: - The test-codegen input defaults to true. All other invocations will run with codegen tests so these will continue to run on merge. Only PRs (from on-pr.yml) set it to false. - Since the number of tests is remarkably smaller without these tests, we can significantly reduce the number of partitions we use for pkg/ unit tests. This should alleviate pressure on GitHub workers further. This is a pretty blunt approach to the problem. If we wanted to be more targeted, instead of filtering at the get-job-matrix.py level, we could instead set an environment variable and add t.Skips in {program,sdk,type}_driver if that environment variable is set. And we can still do that in the future if we decide that maintaining this list is too much. Resolves #12334
2023-03-02 22:33:45 +00:00
id: changes
with:
token: ${{ secrets.GITHUB_TOKEN }}
ci: Don't run codegen tests for PRs We currently run all codegen tests in pkg/codegen/$lang for every PR. These tests take quite a while to run and lock up many GitHub workers for this entire duration. This change attempts to address this issue by running codegen tests only for those PRs that touch the codegen directories. The machinery to make this work is roughly as follows: - In the on-pr workflow, when we're figuring out what we're doing, we check if we've changed codegen files. We use [paths-filter] to do this. - We decide whether we want to run codegen tests based on those files, and pass that onto the test matrix generator. - The test matrix generator filters out these packages and their subpackages from the list of tests under consideration. - Everything else proceeds as normal. [paths-filter]: https://github.com/dorny/paths-filter Things to note: - The test-codegen input defaults to true. All other invocations will run with codegen tests so these will continue to run on merge. Only PRs (from on-pr.yml) set it to false. - Since the number of tests is remarkably smaller without these tests, we can significantly reduce the number of partitions we use for pkg/ unit tests. This should alleviate pressure on GitHub workers further. This is a pretty blunt approach to the problem. If we wanted to be more targeted, instead of filtering at the get-job-matrix.py level, we could instead set an environment variable and add t.Skips in {program,sdk,type}_driver if that environment variable is set. And we can still do that in the future if we decide that maintaining this list is too much. Resolves #12334
2023-03-02 22:33:45 +00:00
filters: |
# If files matching any of these patterns change,
# we will run codegen tests for pull requests.
test-codegen:
- 'pkg/codegen/docs/**'
- 'pkg/codegen/dotnet/**'
- 'pkg/codegen/go/**'
- 'pkg/codegen/nodejs/**'
- 'pkg/codegen/python/**'
outputs:
# Add an entry here for every named pattern
# defined in filters.
test-codegen: ${{ steps.changes.outputs.test-codegen }}
2022-09-02 05:40:13 +00:00
ci:
name: CI
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
ci: Don't run codegen tests for PRs We currently run all codegen tests in pkg/codegen/$lang for every PR. These tests take quite a while to run and lock up many GitHub workers for this entire duration. This change attempts to address this issue by running codegen tests only for those PRs that touch the codegen directories. The machinery to make this work is roughly as follows: - In the on-pr workflow, when we're figuring out what we're doing, we check if we've changed codegen files. We use [paths-filter] to do this. - We decide whether we want to run codegen tests based on those files, and pass that onto the test matrix generator. - The test matrix generator filters out these packages and their subpackages from the list of tests under consideration. - Everything else proceeds as normal. [paths-filter]: https://github.com/dorny/paths-filter Things to note: - The test-codegen input defaults to true. All other invocations will run with codegen tests so these will continue to run on merge. Only PRs (from on-pr.yml) set it to false. - Since the number of tests is remarkably smaller without these tests, we can significantly reduce the number of partitions we use for pkg/ unit tests. This should alleviate pressure on GitHub workers further. This is a pretty blunt approach to the problem. If we wanted to be more targeted, instead of filtering at the get-job-matrix.py level, we could instead set an environment variable and add t.Skips in {program,sdk,type}_driver if that environment variable is set. And we can still do that in the future if we decide that maintaining this list is too much. Resolves #12334
2023-03-02 22:33:45 +00:00
needs: [info, inspect]
2022-09-02 05:40:13 +00:00
uses: ./.github/workflows/ci.yml
permissions:
contents: read
# To sign artifacts.
id-token: write
2022-09-02 05:40:13 +00:00
with:
ref: ${{ github.head_ref }}
2022-09-02 05:40:13 +00:00
version: ${{ needs.info.outputs.version }}
lint: true
# codegen tests are not the fastest, but we want to run them
# on PR to get correct coverage numbers.
test-codegen: true
test-version-sets: >- # No newlines or trailing newline.
${{
contains(github.event.pull_request.labels.*.name, 'ci/test')
&& 'minimum current'
|| 'current'
}}
integration-test-platforms: ubuntu-latest
acceptance-test-platforms: >- # No newlines or trailing newline.
${{
contains(github.event.pull_request.labels.*.name, 'ci/test')
&& 'macos-latest windows-latest'
|| 'windows-latest'
}}
enable-coverage: true
2022-09-02 05:40:13 +00:00
secrets: inherit
performance-gate:
name: Performance Gate
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
needs: [info, inspect]
uses: ./.github/workflows/ci-performance-gate.yml
permissions:
contents: read
with:
ref: ${{ github.ref }}
version: ${{ needs.info.outputs.version }}
test-version-sets: 'minimum current'
performance-test-platforms: ubuntu-latest
secrets: inherit
ci-ok:
name: ci-ok
needs: [ci, performance-gate]
if: always()
runs-on: ubuntu-latest
steps:
# If the PR is a community PR, we don't run the usual checks, but instead
# require maintainers to run them manually by commenting with
# /run-acceptance-tests. Since the checks then run outside of the PR,
# ci-ok is not a useful status in these cases. We thus want to skip this
# job for community PRs. We detect community contributions by checking if
# the head repository is different to the base repository.
- name: CI failed
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && needs.ci.result != 'success' }}
run: exit 1
- name: CI succeeded
run: exit 0