|
| 1 | +--- |
| 2 | + |
| 3 | +name: CI |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: [master] |
| 8 | + pull_request: |
| 9 | + branches: [master] |
| 10 | + schedule: |
| 11 | + # * is a special character in YAML so you have to quote this string |
| 12 | + # Run at 1:00 every day |
| 13 | + - cron: '0 1 * * *' |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + python-version: ["3.9"] |
| 24 | + ci_pattern: |
| 25 | + - test_query.py::TestContentType |
| 26 | + - test_query.py::TestSuccess |
| 27 | + - test_query.py::TestIncorrectFields |
| 28 | + - test_query.py::TestMaxNumResults |
| 29 | + - test_query.py::TestIncludeTargetData |
| 30 | + - test_query.py::TestAcceptHeader |
| 31 | + - test_query.py::TestActiveFlag |
| 32 | + - test_query.py::TestBadImage |
| 33 | + - test_query.py::TestMaximumImageFileSize |
| 34 | + - test_query.py::TestMaximumImageDimensions |
| 35 | + - test_query.py::TestImageFormats |
| 36 | + - test_query.py::TestProcessing |
| 37 | + - test_query.py::TestUpdate |
| 38 | + - test_query.py::TestDeleted |
| 39 | + - test_query.py::TestTargetStatusFailed |
| 40 | + - test_query.py::TestDateFormats |
| 41 | + - test_query.py::TestInactiveProject |
| 42 | + - test_add_target.py |
| 43 | + - test_authorization_header.py::TestAuthorizationHeader |
| 44 | + - test_authorization_header.py::TestMalformed::test_one_part_no_space |
| 45 | + - test_authorization_header.py::TestMalformed::test_one_part_with_space |
| 46 | + - test_authorization_header.py::TestMalformed::test_missing_signature |
| 47 | + - test_authorization_header.py::TestBadKey |
| 48 | + - test_content_length.py::TestIncorrect::test_not_integer |
| 49 | + - test_content_length.py::TestIncorrect::test_too_large |
| 50 | + - test_content_length.py::TestIncorrect::test_too_small |
| 51 | + - test_database_summary.py |
| 52 | + - test_date_header.py::TestFormat |
| 53 | + - test_date_header.py::TestMissing |
| 54 | + - test_date_header.py::TestSkewedTime::test_date_out_of_range |
| 55 | + - test_date_header.py::TestSkewedTime::test_date_in_range |
| 56 | + - test_delete_target.py |
| 57 | + - test_get_duplicates.py |
| 58 | + - test_get_target.py |
| 59 | + - test_invalid_given_id.py |
| 60 | + - test_invalid_json.py |
| 61 | + - test_target_list.py |
| 62 | + - test_target_summary.py |
| 63 | + - test_unexpected_json.py |
| 64 | + - test_update_target.py::TestActiveFlag |
| 65 | + - test_update_target.py::TestApplicationMetadata |
| 66 | + - test_update_target.py::TestImage::test_image_valid |
| 67 | + - test_update_target.py::TestImage::test_bad_image_format_or_color_space |
| 68 | + - test_update_target.py::TestImage::test_corrupted |
| 69 | + - test_update_target.py::TestImage::test_image_too_large |
| 70 | + - test_update_target.py::TestImage::test_not_base64_encoded_processable |
| 71 | + - test_update_target.py::TestImage::test_not_base64_encoded_not_processable |
| 72 | + - test_update_target.py::TestImage::test_not_image |
| 73 | + - test_update_target.py::TestImage::test_invalid_type |
| 74 | + - test_update_target.py::TestImage::test_rating_can_change |
| 75 | + - test_update_target.py::TestTargetName |
| 76 | + - test_update_target.py::TestUnexpectedData |
| 77 | + - test_update_target.py::TestUpdate |
| 78 | + - test_update_target.py::TestWidth |
| 79 | + - test_update_target.py::TestInactiveProject |
| 80 | + - test_requests_mock_usage.py |
| 81 | + - test_flask_app_usage.py |
| 82 | + - test_docker.py |
| 83 | + |
| 84 | + steps: |
| 85 | + # We share Vuforia credentials and therefore Vuforia databases across |
| 86 | + # workflows. |
| 87 | + # We therefore want to run only one workflow at a time. |
| 88 | + - name: Wait for other GitHub Workflows to finish |
| 89 | + uses: softprops/turnstyle@v1 |
| 90 | + with: |
| 91 | + same-branch-only: false |
| 92 | + # By default this is 60. |
| 93 | + # We have a lot of jobs so this is set higher - we hit API timeouts. |
| 94 | + poll-interval-seconds: 300 |
| 95 | + env: |
| 96 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 97 | + |
| 98 | + - uses: actions/checkout@v2 |
| 99 | + with: |
| 100 | + # See https://github.com/codecov/codecov-action/issues/190. |
| 101 | + fetch-depth: 2 |
| 102 | + |
| 103 | + - name: "Set up Python" |
| 104 | + uses: actions/setup-python@v2 |
| 105 | + with: |
| 106 | + python-version: ${{ matrix.python-version }} |
| 107 | + |
| 108 | + - uses: actions/cache@v2 |
| 109 | + with: |
| 110 | + path: ~/.cache/pip |
| 111 | + # This is like the example but we use ``*requirements.txt`` rather |
| 112 | + # than ``requirements.txt`` because we have multiple requirements |
| 113 | + # files. |
| 114 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }} |
| 115 | + restore-keys: | |
| 116 | + ${{ runner.os }}-pip- |
| 117 | +
|
| 118 | + - name: "Install dependencies" |
| 119 | + run: | |
| 120 | + python -m pip install --upgrade pip setuptools wheel |
| 121 | + # We use '--ignore-installed' to avoid GitHub's cache which can cause |
| 122 | + # issues - we have seen packages from this cache be cause trouble with |
| 123 | + # pip-extra-reqs. |
| 124 | + python -m pip install --ignore-installed --upgrade --editable .[dev] |
| 125 | +
|
| 126 | + - name: "Set secrets file" |
| 127 | + run: | |
| 128 | + # See the "CI Setup" document for details of how this was set up. |
| 129 | + ci/decrypt_secret.sh |
| 130 | + tar xvf "${HOME}"/secrets/secrets.tar |
| 131 | + python ci/set_secrets_file.py |
| 132 | + env: |
| 133 | + CI_PATTERN: ${{ matrix.ci_pattern }} |
| 134 | + ENCRYPTED_FILE: secrets.tar.gpg |
| 135 | + LARGE_SECRET_PASSPHRASE: ${{ secrets.PASSPHRASE_FOR_VUFORIA_SECRETS }} |
| 136 | + |
| 137 | + - name: "Run tests" |
| 138 | + run: | |
| 139 | + pytest -s -vvv --exitfirst --cov=src/ --cov=tests --cov-report=xml tests/mock_vws/${{ matrix.ci_pattern }} |
| 140 | +
|
| 141 | + - name: "Show coverage file" |
| 142 | + run: | |
| 143 | + # Sometimes we have been sure that we have 100% coverage, but codecov |
| 144 | + # says otherwise. |
| 145 | + # |
| 146 | + # We show the coverage file here to help with debugging. |
| 147 | + # https://github.com/VWS-Python/vws-python-mock/issues/708 |
| 148 | + cat ./coverage.xml |
| 149 | +
|
| 150 | + # We run this job on every PR, on every merge to master, and nightly. |
| 151 | + # This causes us to hit an issue with Codecov. |
| 152 | + # |
| 153 | + # We see "Too many uploads to this commit.". |
| 154 | + # See https://community.codecov.io/t/too-many-uploads-to-this-commit/2574. |
| 155 | + # |
| 156 | + # To work around this, we do not upload coverage data on scheduled runs. |
| 157 | + # We print the event name here to help with debugging. |
| 158 | + - name: "Show event name" |
| 159 | + run: | |
| 160 | + echo ${{ github.event_name }} |
| 161 | +
|
| 162 | + - name: "Upload coverage to Codecov" |
| 163 | + uses: "codecov/codecov-action@v1" |
| 164 | + with: |
| 165 | + fail_ci_if_error: true |
| 166 | + if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }} |
0 commit comments