Skip to content

Commit 2afd8f3

Browse files
committed
Bring back some existing CI
1 parent c6c0467 commit 2afd8f3

File tree

4 files changed

+424
-0
lines changed

4 files changed

+424
-0
lines changed

.github/workflows/ci.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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' }}

.github/workflows/lint.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
3+
name: Lint
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+
matrix:
22+
python-version: ["3.9"]
23+
24+
steps:
25+
- uses: actions/checkout@v2
26+
- name: "Set up Python"
27+
uses: actions/setup-python@v1
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- uses: actions/cache@v2
32+
with:
33+
path: ~/.cache/pip
34+
# This is like the example but we use ``*requirements.txt`` rather
35+
# than ``requirements.txt`` because we have multiple requirements
36+
# files.
37+
key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }}
38+
restore-keys: |
39+
${{ runner.os }}-pip-
40+
41+
- name: "Install dependencies"
42+
run: |
43+
python -m pip install --upgrade pip setuptools wheel
44+
# We use '--ignore-installed' to avoid GitHub's cache which can cause
45+
# issues - we have seen packages from this cache be cause trouble with
46+
# pip-extra-reqs.
47+
python -m pip install --ignore-installed --upgrade --editable .[dev]
48+
sudo apt-get install -y enchant
49+
50+
- name: "Lint"
51+
run: |
52+
make lint

.github/workflows/release.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
3+
name: Release
4+
5+
on: workflow_dispatch
6+
7+
jobs:
8+
build:
9+
name: Publish a release
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
python-version: ["3.10"]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: "Set up Python"
20+
uses: actions/setup-python@v1
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: "Calver calculate version"
25+
uses: StephaneBour/actions-calver@master
26+
id: calver
27+
with:
28+
date_format: "%Y.%m.%d"
29+
release: false
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
33+
- name: "Update changelog"
34+
uses: jacobtomlinson/gha-find-replace@v2
35+
env:
36+
NEXT_VERSION: ${{ steps.calver.outputs.release }}
37+
with:
38+
find: "Next\n----"
39+
replace: "Next\n----\n\n${{ env.NEXT_VERSION }}\n------------"
40+
include: "CHANGELOG.rst"
41+
regex: false
42+
43+
- uses: stefanzweifel/git-auto-commit-action@v4
44+
id: commit
45+
with:
46+
commit_message: Bump CHANGELOG
47+
48+
- name: Bump version and push tag
49+
id: tag_version
50+
uses: mathieudutour/[email protected]
51+
with:
52+
github_token: ${{ secrets.GITHUB_TOKEN }}
53+
custom_tag: ${{ steps.calver.outputs.release }}
54+
tag_prefix: ""
55+
commit_sha: ${{ steps.commit.outputs.commit_hash }}
56+
57+
- name: Create a GitHub release
58+
uses: ncipollo/release-action@v1
59+
with:
60+
tag: ${{ steps.tag_version.outputs.new_tag }}
61+
name: Release ${{ steps.tag_version.outputs.new_tag }}
62+
body: ${{ steps.tag_version.outputs.changelog }}
63+
64+
- name: Build a binary wheel and a source tarball
65+
run: |
66+
# Checkout the latest tag - the one we just created.
67+
git fetch --tags
68+
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))
69+
python -m pip install build
70+
python -m build --sdist --wheel --outdir dist/ .
71+
72+
- name: Publish distribution 📦 to PyPI
73+
uses: pypa/gh-action-pypi-publish@master
74+
with:
75+
password: ${{ secrets.PYPI_API_TOKEN }}
76+
verbose: true
77+
78+
- name: Login to DockerHub
79+
uses: docker/login-action@v1
80+
with:
81+
username: ${{ secrets.DOCKERHUB_USERNAME }}
82+
password: ${{ secrets.DOCKERHUB_TOKEN }}
83+
84+
- name: Build base Docker image
85+
uses: docker/[email protected]
86+
with:
87+
file: src/mock_vws/_flask_server/dockerfiles/base/Dockerfile
88+
push: false
89+
tags: |
90+
vws-mock:base
91+
92+
- name: Build and push target manager Docker image
93+
uses: docker/[email protected]
94+
with:
95+
file: src/mock_vws/_flask_server/dockerfiles/target_manager/Dockerfile
96+
push: true
97+
tags: |
98+
adamtheturtle/vuforia-target-manager-mock:latest
99+
adamtheturtle/vuforia-target-manager-mock:${{ steps.calver.outputs.release }}
100+
101+
- name: Build and push VWS Docker image
102+
uses: docker/[email protected]
103+
with:
104+
file: src/mock_vws/_flask_server/dockerfiles/vws/Dockerfile
105+
push: true
106+
tags: |
107+
adamtheturtle/vuforia-vws-mock:latest
108+
adamtheturtle/vuforia-vws-mock:${{ steps.calver.outputs.release }}
109+
110+
- name: Build and push VWQ Docker image
111+
uses: docker/[email protected]
112+
with:
113+
file: src/mock_vws/_flask_server/dockerfiles/vwq/Dockerfile
114+
push: true
115+
tags: |
116+
adamtheturtle/vuforia-vwq-mock:latest
117+
adamtheturtle/vuforia-vwq-mock:${{ steps.calver.outputs.release }}

0 commit comments

Comments
 (0)