Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Reduce number of CI jobs run on PRs #13713

Merged
merged 6 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

IS_PR = os.environ["GITHUB_REF"].startswith("refs/pull/")

sqlite_tests = [
# First calculate the various trial jobs.
#
# For each type of test we only run on Py3.7 on PRs

trial_sqlite_tests = [
{
"python-version": "3.7",
"database": "sqlite",
Expand All @@ -29,7 +33,7 @@
]

if not IS_PR:
sqlite_tests.extend(
trial_sqlite_tests.extend(
{
"python-version": version,
"database": "sqlite",
Expand All @@ -39,7 +43,7 @@
)


postgres_tests = [
trial_postgres_tests = [
{
"python-version": "3.7",
"database": "postgres",
Expand All @@ -49,7 +53,7 @@
]

if not IS_PR:
postgres_tests.append(
trial_postgres_tests.append(
{
"python-version": "3.10",
"database": "postgres",
Expand All @@ -58,17 +62,67 @@
}
)

no_extra_tests = [
trial_no_extra_tests = [
{
"python-version": "3.7",
"database": "sqlite",
"extras": "",
}
]

print("::group::Calculated jobs")
print(json.dumps(sqlite_tests + postgres_tests + no_extra_tests, indent=4))
print("::group::Calculated trial jobs")
print(
json.dumps(
trial_sqlite_tests + trial_postgres_tests + trial_no_extra_tests, indent=4
)
)
print("::endgroup::")

test_matrix = json.dumps(
trial_sqlite_tests + trial_postgres_tests + trial_no_extra_tests
)
print(f"::set-output name=trial_test_matrix::{test_matrix}")


# First calculate the various sytest jobs.
#
# For each type of test we only run on focal on PRs


sytest_tests = [
{
"sytest-tag": "focal",
},
{
"sytest-tag": "focal",
"postgres": "postgres",
},
{
"sytest-tag": "focal",
"postgres": "mulit-postgres",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also on 116

"workers": "workers",
},
]

if not IS_PR:
sytest_tests.extend(
[
{
"sytest-tag": "testing",
"postgres": "postgres",
},
{
"sytest-tag": "buster",
"postgres": "mulit-postgres",
"workers": "workers",
},
]
)


print("::group::Calculated sytest jobs")
print(json.dumps(sytest_tests, indent=4))
print("::endgroup::")

test_matrix = json.dumps(sqlite_tests + postgres_tests + no_extra_tests)
print(f"::set-output name=test_matrix::{test_matrix}")
test_matrix = json.dumps(sytest_tests)
print(f"::set-output name=sytest_test_matrix::{test_matrix}")
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
46 changes: 14 additions & 32 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
steps:
- run: "true"

trial-calculate-jobs:
calculate-test-jobs:
if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
needs: linting-done
runs-on: ubuntu-latest
Expand All @@ -83,15 +83,16 @@ jobs:
- id: get-matrix
run: .ci/scripts/calculate_trial_jobs.py
outputs:
test_matrix: ${{ steps.get-matrix.outputs.test_matrix }}
trial_test_matrix: ${{ steps.get-matrix.outputs.trial_test_matrix }}
sytest_test_matrix: ${{ steps.get-matrix.outputs.sytest_test_matrix }}

trial:
if: ${{ !cancelled() && !failure() }} # Allow previous steps to be skipped, but not fail
needs: trial-calculate-jobs
needs: calculate-test-jobs
runs-on: ubuntu-latest
strategy:
matrix:
job: ${{ fromJson(needs.trial-calculate-jobs.outputs.test_matrix) }}
job: ${{ fromJson(needs.calculate-test-jobs.outputs.trial_test_matrix) }}

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -192,45 +193,26 @@ jobs:

sytest:
if: ${{ !failure() && !cancelled() }}
needs: linting-done
needs: calculate-test-jobs
runs-on: ubuntu-latest
container:
image: matrixdotorg/sytest-synapse:${{ matrix.sytest-tag }}
image: matrixdotorg/sytest-synapse:${{ matrix.job.sytest-tag }}
volumes:
- ${{ github.workspace }}:/src
env:
SYTEST_BRANCH: ${{ github.head_ref }}
POSTGRES: ${{ matrix.postgres && 1}}
MULTI_POSTGRES: ${{ (matrix.postgres == 'multi-postgres') && 1}}
WORKERS: ${{ matrix.workers && 1 }}
REDIS: ${{ matrix.redis && 1 }}
BLACKLIST: ${{ matrix.workers && 'synapse-blacklist-with-workers' }}
POSTGRES: ${{ matrix.job.postgres && 1}}
MULTI_POSTGRES: ${{ (matrix.job.postgres == 'multi-postgres') && 1}}
WORKERS: ${{ matrix.job.workers && 1 }}
REDIS: 1
BLACKLIST: ${{ matrix.job.workers && 'synapse-blacklist-with-workers' }}
TOP: ${{ github.workspace }}

strategy:
fail-fast: false
matrix:
include:
- sytest-tag: focal

- sytest-tag: focal
postgres: postgres

- sytest-tag: testing
postgres: postgres

- sytest-tag: focal
postgres: multi-postgres
workers: workers

- sytest-tag: buster
postgres: multi-postgres
workers: workers

- sytest-tag: buster
postgres: postgres
workers: workers
redis: redis
job: ${{ fromJson(needs.calculate-test-jobs.outputs.sytest_test_matrix) }}

steps:
- uses: actions/checkout@v2
Expand All @@ -246,7 +228,7 @@ jobs:
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.*, ', ') }})
name: Sytest Logs - ${{ job.status }} - (${{ join(matrix.job.*, ', ') }})
path: |
/logs/results.tap
/logs/**/*.log*
Expand Down