|
| 1 | +# This is a GitHub workflow defining a set of jobs with a set of steps. |
| 2 | +# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions |
| 3 | +# |
| 4 | +name: Integration tests |
| 5 | + |
1 | 6 | on:
|
2 | 7 | pull_request:
|
| 8 | + paths-ignore: |
| 9 | + - "docs/**" |
| 10 | + - "**.md" |
| 11 | + - "**.rst" |
| 12 | + - ".github/workflows/*" |
| 13 | + - "!.github/workflows/integration-test.yaml" |
3 | 14 | push:
|
| 15 | + paths-ignore: |
| 16 | + - "docs/**" |
| 17 | + - "**.md" |
| 18 | + - "**.rst" |
| 19 | + - ".github/workflows/*" |
| 20 | + - "!.github/workflows/integration-test.yaml" |
| 21 | + branches-ignore: |
| 22 | + - "dependabot/**" |
| 23 | + - "pre-commit-ci-update-config" |
4 | 24 | workflow_dispatch:
|
5 | 25 |
|
6 | 26 | jobs:
|
7 |
| - integration-test: |
8 |
| - runs-on: ubuntu-18.04 |
| 27 | + |
| 28 | + # This job is used as a workaround to a limitation when using a matrix of |
| 29 | + # variations that a job should be executed against. The limitation is that a |
| 30 | + # matrix once defined can't include any conditions. |
| 31 | + # |
| 32 | + # What this job does before our real test job with a matrix of variations run, |
| 33 | + # is to decide on that matrix of variations a conditional logic of our choice. |
| 34 | + # |
| 35 | + # For more details, see this excellent stack overflow answer: |
| 36 | + # https://stackoverflow.com/a/65434401/2220152 |
| 37 | + # |
| 38 | + decide-on-test-jobs-to-run: |
| 39 | + name: Decide on test jobs to run |
| 40 | + runs-on: ubuntu-latest |
| 41 | + |
| 42 | + outputs: |
| 43 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 44 | + |
| 45 | + steps: |
| 46 | + # Currently, this logic filters out a matrix entry equaling a specific git |
| 47 | + # reference identified by "dont_run_on_ref". |
| 48 | + - name: Decide on test jobs to run |
| 49 | + id: set-matrix |
| 50 | + run: | |
| 51 | + matrix_post_filter=$( |
| 52 | + echo "$matrix_include_pre_filter" \ |
| 53 | + | yq e --output-format=json '.' - \ |
| 54 | + | jq '{"include": map( . | select(.dont_run_on_ref != "${{ github.ref }}" ))}' |
| 55 | + ) |
| 56 | + echo ::set-output name=matrix::$(echo "$matrix_post_filter") |
| 57 | +
|
| 58 | + echo "The subsequent job's matrix are:" |
| 59 | + echo $matrix_post_filter | jq '.' |
| 60 | + env: |
| 61 | + matrix_include_pre_filter: | |
| 62 | + - name: "Int. tests: Ubuntu 18.04, Py 3.6" |
| 63 | + ubuntu_version: "18.04" |
| 64 | + python_version: "3.6" |
| 65 | + extra_flags: "" |
| 66 | + - name: "Int. tests: Ubuntu 20.04, Py 3.9" |
| 67 | + ubuntu_version: "20.04" |
| 68 | + python_version: "3.9" |
| 69 | + extra_flags: "" |
| 70 | + - name: "Int. tests: Ubuntu 21.10, Py 3.9" |
| 71 | + runs_on: "20.04" |
| 72 | + ubuntu_version: "21.10" |
| 73 | + python_version: "3.9" |
| 74 | + extra_flags: "" |
| 75 | + - name: "Int. tests: Ubuntu 20.04, Py 3.9, --upgrade" |
| 76 | + ubuntu_version: "20.04" |
| 77 | + python_version: "3.9" |
| 78 | + extra_flags: --upgrade |
| 79 | + dont_run_on_ref: refs/heads/master |
| 80 | +
|
| 81 | + integration-tests: |
| 82 | + needs: decide-on-test-jobs-to-run |
| 83 | + |
| 84 | + # runs-on can only be configured to the LTS releases of ubuntu (18.04, |
| 85 | + # 20.04, ...), so if we want to test against the latest non-LTS release, we |
| 86 | + # must compromise when configuring runs-on and configure runs-on to be the |
| 87 | + # latest LTS release instead. |
| 88 | + # |
| 89 | + # This can have consequences because actions like actions/setup-python will |
| 90 | + # mount cached installations associated with the chosen runs-on environment. |
| 91 | + # |
| 92 | + runs-on: ${{ format('ubuntu-{0}', matrix.runs_on || matrix.ubuntu_version) }} |
| 93 | + |
| 94 | + name: ${{ matrix.name }} |
| 95 | + strategy: |
| 96 | + fail-fast: false |
| 97 | + matrix: ${{ fromJson(needs.decide-on-test-jobs-to-run.outputs.matrix) }} |
| 98 | + |
9 | 99 | steps:
|
10 | 100 | - uses: actions/checkout@v2
|
11 | 101 | - uses: actions/setup-python@v2
|
12 | 102 | with:
|
13 |
| - python-version: 3.6 |
14 |
| - - name: Set BOOTSTRAP_PIP_SPEC value |
| 103 | + python-version: ${{ matrix.python_version }} |
| 104 | + |
| 105 | + - name: Install pytest |
| 106 | + run: python3 -m pip install pytest |
| 107 | + |
| 108 | + # We abort pytest after two failures as a compromise between wanting to |
| 109 | + # avoid a flood of logs while still understanding if multiple tests would |
| 110 | + # fail. |
| 111 | + - name: Run bootstrap tests (Runs in/Builds ubuntu:${{ matrix.ubuntu_version }} derived image) |
15 | 112 | run: |
|
16 |
| - echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV |
17 |
| - - name: Build systemd image |
| 113 | + pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no \ |
| 114 | + integration-tests/test_bootstrap.py |
| 115 | + timeout-minutes: 15 |
| 116 | + env: |
| 117 | + # integration-tests/test_bootstrap.py will build and start containers |
| 118 | + # based on this environment variable. This is similar to how |
| 119 | + # .github/integration-test.py build-image can take a --build-arg |
| 120 | + # setting the ubuntu_version. |
| 121 | + UBUNTU_VERSION: ${{ matrix.ubuntu_version }} |
| 122 | + |
| 123 | + # We build a docker image from wherein we will work |
| 124 | + - name: Build systemd image (Builds ubuntu:${{ matrix.ubuntu_version }} derived image) |
18 | 125 | run: |
|
19 |
| - .github/integration-test.py build-image |
20 |
| - - name: Run bootstrap checks |
| 126 | + .github/integration-test.py build-image \ |
| 127 | + --build-arg "ubuntu_version=${{ matrix.ubuntu_version }}" |
| 128 | +
|
| 129 | + # FIXME: Make the logic below easier to follow. |
| 130 | + # - In short, setting BOOTSTRAP_PIP_SPEC here, specifies from what |
| 131 | + # location the tljh python package should be installed from. In this |
| 132 | + # GitHub Workflow's test job, we provide a remote reference to itself as |
| 133 | + # found on GitHub - this could be the HEAD of a PR branch or the default |
| 134 | + # branch on merge. |
| 135 | + # |
| 136 | + # Overview of how this logic influences the end result. |
| 137 | + # - integration-test.yaml: |
| 138 | + # Runs integration-test.py by passing --bootstrap-pip-spec flag with a |
| 139 | + # reference to the pull request on GitHub. |
| 140 | + # - integration-test.py: |
| 141 | + # Starts a pre-build systemd container, setting the |
| 142 | + # TLJH_BOOTSTRAP_PIP_SPEC based on its passed --bootstrap-pip-spec value. |
| 143 | + # - systemd container: |
| 144 | + # Runs bootstrap.py |
| 145 | + # - bootstrap.py |
| 146 | + # Makes use of TLJH_BOOTSTRAP_PIP_SPEC environment variable to install |
| 147 | + # the tljh package from a given location, which could be a local git |
| 148 | + # clone of this repo where setup.py resides, or a reference to some |
| 149 | + # GitHub branch for example. |
| 150 | + - name: Set BOOTSTRAP_PIP_SPEC value |
21 | 151 | run: |
|
22 |
| - python3 -m pip install pytest |
23 |
| - pytest integration-tests/test_bootstrap.py -s |
24 |
| - - name: Run basic tests |
| 152 | + echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV |
| 153 | + echo $BOOTSTRAP_PIP_SPEC |
| 154 | +
|
| 155 | + - name: Run basic tests (Runs in ubuntu:${{ matrix.ubuntu_version }} derived image) |
25 | 156 | run: |
|
26 |
| - .github/integration-test.py run-test \ |
27 |
| - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ |
28 |
| - basic-tests test_hub.py test_proxy.py \ |
29 |
| - test_install.py test_extensions.py |
30 |
| - - name: Run admin tests |
| 157 | + .github/integration-test.py run-test basic-tests \ |
| 158 | + --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ |
| 159 | + ${{ matrix.extra_flags }} \ |
| 160 | + test_hub.py \ |
| 161 | + test_proxy.py \ |
| 162 | + test_install.py \ |
| 163 | + test_extensions.py |
| 164 | + timeout-minutes: 15 |
| 165 | + |
| 166 | + - name: Run admin tests (Runs in ubuntu:${{ matrix.ubuntu_version }} derived image) |
31 | 167 | run: |
|
32 |
| - .github/integration-test.py run-test \ |
33 |
| - --installer-args "--admin admin:admin" \ |
34 |
| - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ |
35 |
| - basic-tests test_admin_installer.py \ |
36 |
| - - name: Run plugin tests |
| 168 | + .github/integration-test.py run-test admin-tests \ |
| 169 | + --installer-args "--admin admin:admin" \ |
| 170 | + --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ |
| 171 | + ${{ matrix.extra_flags }} \ |
| 172 | + test_admin_installer.py |
| 173 | + timeout-minutes: 15 |
| 174 | + |
| 175 | + - name: Run plugin tests (Runs in ubuntu:${{ matrix.ubuntu_version }} derived image) |
37 | 176 | run: |
|
38 |
| - .github/integration-test.py run-test \ |
39 |
| - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ |
40 |
| - --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ |
41 |
| - plugins test_simplest_plugin.py \ |
| 177 | + .github/integration-test.py run-test plugin-tests \ |
| 178 | + --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ |
| 179 | + --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ |
| 180 | + ${{ matrix.extra_flags }} \ |
| 181 | + test_simplest_plugin.py |
| 182 | + timeout-minutes: 15 |
0 commit comments