-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Run CI tests against multiple versions
- Loading branch information
Showing
5 changed files
with
168 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,96 +115,172 @@ jobs: | |
SHELLCHECK_OPTS: --exclude=SC2086 --exclude=SC2046 --exclude=SC2004 --exclude=SC2129 | ||
|
||
|
||
unit-tests: | ||
strategy: | ||
matrix: | ||
python-version: | ||
- "3.9" | ||
- "3.10" | ||
- "3.11" | ||
- "3.12" | ||
- "3.13" | ||
if: | | ||
always() && !cancelled() && | ||
!contains(needs.*.result, 'failure') && | ||
!contains(needs.*.result, 'cancelled') && | ||
needs.files-changed.outputs.python == 'true' | ||
needs: ["files-changed", "yaml-lint", "python-lint"] | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- name: "Check out repository code" | ||
uses: "actions/checkout@v4" | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: "Setup environment" | ||
run: | | ||
pipx install poetry==1.8.5 | ||
poetry config virtualenvs.create true --local | ||
pip install invoke toml codecov | ||
- name: "Install Package" | ||
run: "poetry install --all-extras" | ||
- name: "Mypy Tests" | ||
run: "poetry run mypy --show-error-codes infrahub_sdk/" | ||
# - name: "Pylint Tests" | ||
# run: "poetry run pylint infrahub_sdk/" | ||
- name: "Unit Tests" | ||
run: "poetry run pytest --cov infrahub_sdk tests/unit/" | ||
- name: "Upload coverage to Codecov" | ||
run: | | ||
codecov --flags python-${{ matrix.python-version }} | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
# The pytest-cov plugin doesn't quite work with content that is | ||
# auto-imported by our own infrahub pytest plugin, this workaround | ||
# reports the missing lines | ||
- name: "Report coverage for pytest-plugin" | ||
if: matrix.python-version == '3.12' | ||
run: | | ||
source $(poetry env info --path)/bin/activate | ||
coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin | ||
coverage report -m | ||
coverage xml | ||
codecov --flags python-filler-${{ matrix.python-version }} | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
# unit-tests: | ||
# strategy: | ||
# matrix: | ||
# python-version: | ||
# - "3.9" | ||
# - "3.10" | ||
# - "3.11" | ||
# - "3.12" | ||
# - "3.13" | ||
# if: | | ||
# always() && !cancelled() && | ||
# !contains(needs.*.result, 'failure') && | ||
# !contains(needs.*.result, 'cancelled') && | ||
# needs.files-changed.outputs.python == 'true' | ||
# needs: ["files-changed", "yaml-lint", "python-lint"] | ||
# runs-on: ubuntu-latest | ||
# timeout-minutes: 30 | ||
# steps: | ||
# - name: "Check out repository code" | ||
# uses: "actions/checkout@v4" | ||
# - name: Set up Python ${{ matrix.python-version }} | ||
# uses: actions/setup-python@v5 | ||
# with: | ||
# python-version: ${{ matrix.python-version }} | ||
# - name: "Setup environment" | ||
# run: | | ||
# pipx install poetry==1.8.5 | ||
# poetry config virtualenvs.create true --local | ||
# pip install invoke toml codecov | ||
# - name: "Install Package" | ||
# run: "poetry install --all-extras" | ||
# - name: "Mypy Tests" | ||
# run: "poetry run mypy --show-error-codes infrahub_sdk/" | ||
# # - name: "Pylint Tests" | ||
# # run: "poetry run pylint infrahub_sdk/" | ||
# - name: "Unit Tests" | ||
# run: "poetry run pytest --cov infrahub_sdk tests/unit/" | ||
# - name: "Upload coverage to Codecov" | ||
# run: | | ||
# codecov --flags python-${{ matrix.python-version }} | ||
# env: | ||
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
# | ||
# # The pytest-cov plugin doesn't quite work with content that is | ||
# # auto-imported by our own infrahub pytest plugin, this workaround | ||
# # reports the missing lines | ||
# - name: "Report coverage for pytest-plugin" | ||
# if: matrix.python-version == '3.12' | ||
# run: | | ||
# source $(poetry env info --path)/bin/activate | ||
# coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin | ||
# coverage report -m | ||
# coverage xml | ||
# codecov --flags python-filler-${{ matrix.python-version }} | ||
# env: | ||
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
# ------------------------------------------ Integration Tests ------------------------------------------ | ||
integration-tests: | ||
# integration-tests: | ||
# if: | | ||
# always() && !cancelled() && | ||
# !contains(needs.*.result, 'failure') && | ||
# !contains(needs.*.result, 'cancelled') && | ||
# needs.files-changed.outputs.python == 'true' | ||
# needs: ["files-changed", "yaml-lint", "python-lint"] | ||
# runs-on: | ||
# group: "huge-runners" | ||
# timeout-minutes: 30 | ||
# strategy: | ||
# matrix: | ||
# version: ["1.0.0", "1.1.0"] | ||
# steps: | ||
# - name: "Check out repository code" | ||
# uses: "actions/checkout@v4" | ||
# - name: Set up Python | ||
# uses: actions/setup-python@v5 | ||
# with: | ||
# python-version: "3.12" | ||
# - name: "Set environment variables" | ||
# run: | | ||
# RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/') | ||
# echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV | ||
# - name: "Setup environment" | ||
# run: | | ||
# pipx install poetry==1.8.5 | ||
# poetry config virtualenvs.create true --local | ||
# pip install invoke toml codecov | ||
# - name: "Install Package" | ||
# run: "poetry install --all-extras" | ||
# - name: "Set environment variables for python_testcontainers" | ||
# run: | | ||
# echo INFRAHUB_TESTING_IMAGE_VER=${{ matrix.version }} >> $GITHUB_ENV | ||
# - name: "Integration Tests" | ||
# run: | | ||
# echo "Running tests for version: ${{ matrix.version }}" | ||
# poetry run pytest --cov infrahub_sdk tests/integration/ | ||
# - name: "Upload coverage to Codecov" | ||
# run: | | ||
# codecov --flags integration-tests | ||
# env: | ||
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
integration-tests-against-local-infrahub-build: | ||
if: | | ||
always() && !cancelled() && | ||
!contains(needs.*.result, 'failure') && | ||
!contains(needs.*.result, 'cancelled') && | ||
needs.files-changed.outputs.python == 'true' | ||
needs: ["files-changed", "yaml-lint", "python-lint"] | ||
needs: [ "files-changed", "yaml-lint", "python-lint" ] | ||
Check failure on line 225 in .github/workflows/ci.yml
|
||
runs-on: | ||
group: "huge-runners" | ||
timeout-minutes: 30 | ||
steps: | ||
- name: "Check out repository code" | ||
uses: "actions/checkout@v4" | ||
|
||
- name: "Checkout infrahub repository" | ||
uses: "actions/checkout@v4" | ||
with: | ||
repository: "opsmill/infrahub" | ||
path: "infrahub-server" | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
- name: "Set environment variables" | ||
|
||
- name: "Setup git credentials prior dev.build" | ||
run: | | ||
cd infrahub-server | ||
git config --global user.name 'Infrahub' | ||
git config --global user.email '[email protected]' | ||
git config --global --add safe.directory '*' | ||
git config --global credential.usehttppath true | ||
git config --global credential.helper /usr/local/bin/infrahub-git-credential | ||
- name: "Set environment variables prior dev.build" | ||
run: | | ||
echo "INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }}" >> $GITHUB_ENV | ||
RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/') | ||
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV | ||
echo "INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV | ||
echo "INFRAHUB_TESTING_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV | ||
echo "INFRAHUB_TESTING_DOCKER_IMAGE=opsmill/infrahub" >> $GITHUB_ENV | ||
- name: "Build container" | ||
run: | | ||
cd infrahub-server | ||
inv dev.build | ||
- name: "Setup environment" | ||
run: | | ||
pipx install poetry==1.8.5 | ||
poetry config virtualenvs.create true --local | ||
pip install invoke toml codecov | ||
- name: "Install Package" | ||
run: "poetry install --all-extras" | ||
|
||
- name: "Integration Tests" | ||
run: "poetry run pytest --cov infrahub_sdk tests/integration/" | ||
run: | | ||
echo "Running tests for version: $INFRAHUB_TESTING_DOCKER_IMAGE" | ||
poetry run pytest --cov infrahub_sdk tests/integration/ | ||
- name: "Upload coverage to Codecov" | ||
run: | | ||
codecov --flags integration-tests | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters