Skip to content

Test

Test #1762

Workflow file for this run

---
name: "Test"
on: # yamllint disable-line rule:truthy
push:
branches: [master]
tags: ["*"]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '43 16 * * 5'
env:
# https://github.com/pypa/pipenv/releases
PIPENV_INSTALL_VERSION: "2024.1.0"
PYTHON_VERSION: "3.11"
# How long to run the executable automated tests
TEST_DURATION_SECONDS: 60
# https://github.com/upx/upx/releases
UPX_VERSION: "4.2.4"
jobs:
pipenv-cache:
# This job is used to refresh the pipenv cache so that both the test and
# build job can use it.
name: Refresh pipenv cache
runs-on: windows-latest
steps:
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Set up Python
# https://github.com/actions/setup-python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pipenv'
# Add Scripts directory to the path so that pipenv (and associated
# utilities) can be used once installed
- name: Add python Scripts directory to path
shell: cmd
# Code-page switch is needed to write the env file as utf-8
run: |
chcp 65001
python -c "import site; print(site.USER_SITE.replace('site-packages', 'Scripts'))" >> %GITHUB_PATH%
chcp 1252
- name: Install pipenv
shell: cmd
run: python -m pip install --user pipenv==${{ env.PIPENV_INSTALL_VERSION }}
- name: Initialize virtual environment
shell: cmd
run: pipenv sync --dev --no-site-packages -v
test:
name: Test
runs-on: windows-latest
needs: [pipenv-cache]
steps:
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Set up Python
# https://github.com/actions/setup-python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pipenv'
- name: Enable cache for pre-commit hooks
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit|${{ env.pythonLocation }}
pre-commit|
# Add Scripts directory to the path so that pipenv (and associated
# utilities) can be used once installed
- name: Add python Scripts directory to path
shell: cmd
# Code-page switch is needed to write the env file as utf-8
run: |
chcp 65001
python -c "import site; print(site.USER_SITE.replace('site-packages', 'Scripts'))" >> %GITHUB_PATH%
chcp 1252
- name: Install pipenv
shell: cmd
run: python -m pip install --user pipenv==${{ env.PIPENV_INSTALL_VERSION }}
- name: Initialize virtual environment
shell: cmd
run: pipenv sync --dev --no-site-packages -v
- name: Run pre-commit checks
shell: cmd
run: pipenv run pre-commit run -a
- name: Run pre-commit gc
shell: cmd
run: pipenv run pre-commit gc
- name: Run tests
shell: cmd
run: pipenv run pytest -v
- name: Build docs
shell: cmd
run: pipenv run mkdocs build --verbose --strict
build:
name: Build
runs-on: windows-latest
needs: [pipenv-cache]
steps:
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Set up Python
# https://github.com/actions/setup-python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pipenv'
# Add Scripts directory to the path so that pipenv (and associated
# utilities) can be used once installed
- name: Add python Scripts directory to path
shell: cmd
# Code-page switch is needed to write the env file as utf-8
run: |
chcp 65001
python -c "import site; print(site.USER_SITE.replace('site-packages', 'Scripts'))" >> %GITHUB_PATH%
chcp 1252
- name: Install pipenv
shell: cmd
run: python -m pip install --user pipenv==${{ env.PIPENV_INSTALL_VERSION }}
- name: Initialize virtual environment
shell: cmd
run: |
pipenv sync --no-site-packages -v
pipenv clean -v
- name: Install UPX
shell: cmd
run: choco install -y upx --version ${{ env.UPX_VERSION }}
- name: Build executable
shell: cmd
env:
IPINFO_TOKEN: ${{ secrets.IPINFO_TOKEN }}
SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
run: pipenv run python build.py
- name: Save executable as artifact
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: wahoo-results.exe
path: wahoo-results.exe
if-no-files-found: error
autotest:
name: Autotest
needs: [build]
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
fetch-depth: 0
- name: Load executable artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: wahoo-results.exe
- name: Ensure config file does not exist
shell: bash
run: |
[[ ! -e wahoo-results.ini ]]
- name: Run autotest (no config file)
timeout-minutes: 3
shell: cmd
run: wahoo-results.exe --loglevel=debug --test scripted:${{ env.TEST_DURATION_SECONDS }}
- name: Ensure config file exists
shell: bash
run: |
[[ -e wahoo-results.ini ]]
- name: Run autotest (with config file)
timeout-minutes: 3
shell: cmd
run: wahoo-results.exe --loglevel=debug --test scripted:${{ env.TEST_DURATION_SECONDS }}
success:
name: Successful CI
needs: [autotest, test]
runs-on: windows-latest
steps:
- name: Success
shell: cmd
run: echo "CI was successful"
release:
name: Publish release
if: startsWith(github.ref, 'refs/tags/v')
needs: [success]
runs-on: windows-latest
permissions:
contents: write
discussions: write
steps:
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0
with:
python-version: ${{ env.PYTHON_VERSION }}
# Add Scripts directory to the path so that utilities can be used once installed
- name: Add python Scripts directory to path
shell: cmd
# Code-page switch is needed to write the env file as utf-8
run: |
chcp 65001
python -c "import site; print(site.USER_SITE.replace('site-packages', 'Scripts'))" >> %GITHUB_PATH%
chcp 1252
- name: Install sentry-cli
shell: cmd
run: python -m pip install --user sentry-cli
- name: Download executable as artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: wahoo-results.exe
- name: Create sentry release
shell: cmd
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: wahoo-results
SENTRY_PROJECT: wahoo-results
run: |
sentry-cli releases new --finalize wahoo-results@${{ github.ref_name }}
sentry-cli releases set-commits wahoo-results@${{ github.ref_name }} --commit JohnStrunk/wahoo-results@${{ github.ref_name }}
- name: Publish release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@c062e08bd532815e2082a85e87e3ef29c3e6d191 # v2.0.8
with:
name: Release ${{ github.ref_name }}
draft: true
files: |
wahoo-results.exe