IFC-41 cache enriched diff #8196
Workflow file for this run
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
--- | |
# yamllint disable rule:truthy rule:truthy rule:line-length | |
name: "CI" | |
on: | |
pull_request: | |
push: | |
branches: | |
- develop | |
- stable | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
INFRAHUB_DB_USERNAME: neo4j | |
INFRAHUB_DB_PASSWORD: admin | |
INFRAHUB_DB_ADDRESS: localhost | |
INFRAHUB_DB_PORT: 7687 | |
INFRAHUB_DB_PROTOCOL: bolt | |
INFRAHUB_BROKER_ADDRESS: message-queue | |
INFRAHUB_LOG_LEVEL: CRITICAL | |
INFRAHUB_IMAGE_NAME: "opsmill/infrahub" | |
INFRAHUB_IMAGE_VER: "local" | |
PYTEST_XDIST_WORKER_COUNT: 4 | |
INFRAHUB_TEST_IN_DOCKER: 1 | |
VALE_VERSION: "3.0.7" | |
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }} | |
METRICS_ENDPOINT: ${{ secrets.METRICS_ENDPOINT }} | |
jobs: | |
# ------------------------------------------ Check Files Changes ------------------------------------------ | |
files-changed: | |
name: Detect which file has changed | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
outputs: | |
backend: ${{ steps.changes.outputs.backend_all }} | |
documentation: ${{ steps.changes.outputs.documentation_all }} | |
frontend: ${{ steps.changes.outputs.frontend_all }} | |
helm: ${{ steps.changes.outputs.helm_all }} | |
sdk: ${{ steps.changes.outputs.sdk_all }} | |
sync: ${{ steps.changes.outputs.sync_all }} | |
e2e: ${{ steps.changes.outputs.e2e_all }} | |
python: ${{ steps.changes.outputs.python_all }} | |
javascript: ${{ steps.changes.outputs.javascript_all }} | |
yaml: ${{ steps.changes.outputs.yaml_all }} | |
infrahub_poetry_files: ${{ steps.changes.outputs.infrahub_poetry_files }} | |
python_sdk_poetry_files: ${{ steps.changes.outputs.python_sdk_poetry_files }} | |
sync_poetry_files: ${{ steps.changes.outputs.sync_poetry_files }} | |
github_workflows: ${{ steps.changes.outputs.github_workflows }} | |
e2e_tests: ${{ steps.changes.outputs.e2e_test_files }} | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: Check for file changes | |
uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
token: ${{ github.token }} | |
filters: .github/file-filters.yml | |
# ------------------------------------------ All Linter ------------------------------------------ | |
helm-lint: | |
if: needs.files-changed.outputs.helm == 'true' | |
needs: ["files-changed"] | |
runs-on: "ubuntu-latest" | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Install Helm" | |
uses: azure/[email protected] | |
- name: "Linting: helm lint" | |
run: "helm lint helm/" | |
yaml-lint: | |
if: needs.files-changed.outputs.yaml == 'true' | |
needs: ["files-changed"] | |
runs-on: "ubuntu-latest" | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Setup environment" | |
run: "pip install yamllint==1.35.1" | |
- name: "Linting: yamllint" | |
run: "yamllint -s ." | |
javascript-lint: | |
if: needs.files-changed.outputs.javascript == 'true' | |
needs: ["files-changed"] | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: Install NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
cache-dependency-path: frontend/app/package-lock.json | |
- name: Install frontend dependencies | |
working-directory: ./frontend/app | |
run: npm install | |
- name: Run ESLint | |
working-directory: ./frontend/app | |
run: npm run eslint | |
python-lint: | |
if: needs.files-changed.outputs.python == 'true' | |
needs: ["files-changed"] | |
runs-on: "ubuntu-latest" | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Setup environment" | |
run: "pip install ruff==0.5.0" | |
- name: "Linting: ruff check" | |
run: "ruff check ." | |
- name: "Linting: ruff format" | |
run: "ruff format --check --diff ." | |
markdown-lint: | |
if: needs.files-changed.outputs.documentation == 'true' | |
needs: ["files-changed"] | |
runs-on: "ubuntu-latest" | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Linting: markdownlint" | |
uses: DavidAnson/markdownlint-cli2-action@v16 | |
with: | |
config: .markdownlint.yaml | |
globs: '**/*.{md,mdx}' | |
action-lint: | |
if: needs.files-changed.outputs.github_workflows == 'true' | |
needs: ["files-changed"] | |
runs-on: "ubuntu-latest" | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: Check workflow files | |
run: | | |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) | |
./actionlint -color | |
shell: bash | |
env: | |
SHELLCHECK_OPTS: --exclude=SC2086 --exclude=SC2046 --exclude=SC2004 | |
infrahub-poetry-check: | |
if: | | |
needs.files-changed.outputs.infrahub_poetry_files == 'true' || | |
github.ref_name == 'stable' || | |
github.ref_name == 'develop' | |
needs: | |
- "files-changed" | |
uses: "./.github/workflows/poetry-check.yml" | |
with: | |
directory: "./" | |
python-sdk-poetry-check: | |
if: | | |
needs.files-changed.outputs.python_sdk_poetry_files == 'true' || | |
github.ref_name == 'stable' || | |
github.ref_name == 'develop' | |
needs: | |
- "files-changed" | |
uses: "./.github/workflows/poetry-check.yml" | |
with: | |
directory: "./python-sdk/" | |
sync-poetry-check: | |
if: | | |
needs.files-changed.outputs.sync_poetry_files == 'true' || | |
github.ref_name == 'stable' || | |
github.ref_name == 'develop' | |
needs: | |
- "files-changed" | |
uses: "./.github/workflows/poetry-check.yml" | |
with: | |
directory: "./sync/" | |
python-sdk-unit-tests: | |
strategy: | |
matrix: | |
python-version: | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.sdk == 'true' | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
env: | |
INFRAHUB_DB_TYPE: memgraph | |
defaults: | |
run: | |
working-directory: python_sdk/ | |
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 | |
poetry config virtualenvs.prefer-active-python true | |
pip install invoke toml | |
- 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 --directory python_sdk run coverage run --source=infrahub_sdk -m pytest python_sdk/tests/unit/" | |
working-directory: ./ | |
- name: "Create coverage file" | |
run: "poetry --directory python_sdk run coverage xml" | |
working-directory: ./ | |
- name: "Coveralls : Unit Tests" | |
uses: coverallsapp/github-action@v2 | |
continue-on-error: true | |
env: | |
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | |
with: | |
flag-name: python-sdk-unit | |
parallel: true | |
python-sdk-integration-tests: | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
needs: ["python-sdk-unit-tests"] | |
runs-on: | |
group: huge-runners | |
timeout-minutes: 30 | |
env: | |
INFRAHUB_DB_TYPE: memgraph | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Install Invoke" | |
run: "pip install toml invoke" | |
- name: "Set environment variables" | |
run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }} >> $GITHUB_ENV | |
- name: "Clear docker environment" | |
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local | |
- name: "Build Test Image" | |
run: "invoke dev.build" | |
- name: "Pull External Docker Images" | |
run: "invoke dev.pull" | |
- name: "Integration Tests" | |
run: "invoke sdk.test-integration" | |
- name: "Coveralls : Integration Tests" | |
uses: coverallsapp/github-action@v2 | |
continue-on-error: true | |
env: | |
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | |
with: | |
flag-name: python-sdk-integration | |
parallel: true | |
infrahub-sync-unit-tests: | |
strategy: | |
matrix: | |
python-version: | |
- "3.9" | |
- "3.10" | |
- "3.11" | |
- "3.12" | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.sync == 'true' | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
defaults: | |
run: | |
working-directory: sync/ | |
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 | |
poetry config virtualenvs.prefer-active-python true | |
pip install invoke toml | |
- name: "Install Package" | |
run: "poetry install" | |
- name: "Pylint Tests" | |
run: "poetry run pylint infrahub_sync/" | |
# - name: "Mypy Tests" | |
# run: "poetry run mypy --show-error-codes infrahub_sync/" | |
backend-tests-unit: | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.backend == 'true' | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: | |
group: huge-runners | |
timeout-minutes: 45 | |
env: | |
INFRAHUB_DB_TYPE: memgraph | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Setup Python environment" | |
run: "pip install toml invoke" | |
- name: "Set environment variables" | |
run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }} >> $GITHUB_ENV | |
- name: "Clear docker environment" | |
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local | |
- name: "Build Test Image" | |
run: "invoke dev.build" | |
- name: "Pull External Docker Images" | |
run: "invoke dev.pull" | |
- name: "Unit Tests" | |
run: "invoke backend.test-unit" | |
- name: "Coveralls : Unit Tests" | |
uses: coverallsapp/github-action@v2 | |
continue-on-error: true | |
env: | |
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | |
with: | |
flag-name: backend-unit | |
parallel: true | |
- name: Generate tracing spans | |
if: always() && github.event.pull_request.head.repo.fork == false | |
uses: inception-health/otel-upload-test-artifact-action@v1 | |
with: | |
jobName: "backend-tests-unit" | |
stepName: "Unit Tests" | |
path: "pytest-junit.xml" | |
type: "junit" | |
githubToken: ${{ secrets.GH_TRACING_REPO_TOKEN }} | |
backend-tests-integration: | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.backend == 'true' | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: | |
group: "huge-runners" | |
timeout-minutes: 30 | |
env: | |
INFRAHUB_DB_TYPE: neo4j | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Setup Python environment" | |
run: "pip install toml invoke" | |
- name: "Set environment variables" | |
run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }} >> $GITHUB_ENV | |
- name: "Clear docker environment" | |
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local | |
- name: "Build Test Image" | |
run: "invoke dev.build" | |
- name: "Pull External Docker Images" | |
run: "invoke dev.pull" | |
- name: "Mypy Tests" | |
run: "invoke backend.mypy --docker" | |
- name: "Pylint Tests" | |
run: "invoke backend.pylint --docker" | |
- name: "Integration Tests" | |
run: "invoke backend.test-integration" | |
- name: "Coveralls : Integration Tests" | |
uses: coverallsapp/github-action@v2 | |
continue-on-error: true | |
env: | |
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | |
with: | |
flag-name: backend-integration | |
parallel: true | |
backend-tests-neo4j: | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.backend == 'true' | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: | |
group: huge-runners | |
timeout-minutes: 45 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: backend-tests-neo4j | |
env: | |
INFRAHUB_DB_TYPE: neo4j | |
- name: backend-tests-nats | |
env: | |
INFRAHUB_DB_TYPE: memgraph | |
INFRAHUB_USE_NATS: 1 | |
INFRAHUB_BROKER_DRIVER: nats | |
INFRAHUB_BROKER_PORT: 4222 | |
INFRAHUB_CACHE_DRIVER: nats | |
INFRAHUB_CACHE_ADDRESS: message-queue | |
INFRAHUB_CACHE_PORT: 4222 | |
name: ${{ matrix.name }} | |
env: ${{ matrix.env }} | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: "Setup Python environment" | |
run: "pip install toml invoke" | |
- name: "Set environment variables" | |
run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }} >> $GITHUB_ENV | |
- name: "Clear docker environment" | |
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local | |
- name: "Build Test Image" | |
run: "invoke dev.build" | |
- name: "Pull External Docker Images" | |
run: "invoke dev.pull" | |
- name: "Unit Tests" | |
run: "invoke backend.test-unit" | |
backend-validate-generated: | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
(needs.files-changed.outputs.backend == 'true' || | |
needs.files-changed.outputs.documentation == 'true') | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: ubuntu-latest | |
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: "Setup environment" | |
run: | | |
pipx install poetry | |
poetry config virtualenvs.prefer-active-python true | |
pip install invoke toml | |
- name: "Install Package" | |
run: "poetry install" | |
- name: "Run validator" | |
run: "poetry run invoke backend.validate-generated" | |
frontend-tests: | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.frontend == 'true' | |
needs: ["files-changed", "yaml-lint", "javascript-lint"] | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 30 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: Install NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
cache-dependency-path: frontend/app/package-lock.json | |
- name: "Install frontend" | |
working-directory: ./frontend/app | |
run: npm install | |
- name: "Run unit tests" | |
working-directory: ./frontend/app | |
run: "npm run test:coverage" | |
- name: "Run integration tests" | |
working-directory: ./frontend/app | |
run: "npm run cypress:run" | |
- name: Upload cypress screenshots | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshots | |
path: docs/media/* | |
- name: Upload cypress videos | |
if: failure() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: screenshots | |
path: frontend/app/cypress/videos/* | |
- name: "Coveralls : Unit Tests" | |
uses: coverallsapp/github-action@v2 | |
continue-on-error: true | |
env: | |
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | |
with: | |
flag-name: frontend-unit | |
parallel: true | |
file: frontend/app/coverage/lcov.info | |
documentation: | |
defaults: | |
run: | |
working-directory: ./docs | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.documentation == 'true' | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
- name: Install NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
- name: "Install dependencies" | |
run: npm install | |
- name: "Setup Python environment" | |
run: "pip install toml invoke" | |
- name: "Build website" | |
run: "invoke docs.build" | |
validate-generated-documentation: | |
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-22.04" | |
timeout-minutes: 5 | |
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: "Setup environment" | |
run: "pip install invoke toml" | |
- name: "Build Test Image" | |
run: "invoke dev.build" | |
- name: "Validate generated documentation" | |
run: "invoke docs.validate --docker" | |
validate-documentation-style: | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.documentation == 'true' | |
needs: ["files-changed", "yaml-lint", "python-lint"] | |
runs-on: "ubuntu-22.04" | |
timeout-minutes: 5 | |
steps: | |
- name: "Check out repository code" | |
uses: "actions/checkout@v4" | |
# The official GitHub Action for Vale doesn't work, installing manually instead: | |
# https://github.com/errata-ai/vale-action/issues/103 | |
- name: Download Vale | |
run: | | |
curl -sL "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz" -o vale.tar.gz | |
tar -xzf vale.tar.gz | |
env: | |
VALE_VERSION: ${{ env.VALE_VERSION }} | |
- name: "Validate documentation style" | |
run: "./vale ." | |
# ------------------------------------------ E2E Tests ------------------------------------------ | |
E2E-testing-playwright: | |
defaults: | |
run: | |
working-directory: ./frontend/app | |
needs: | |
- javascript-lint | |
- files-changed | |
- yaml-lint | |
- python-lint | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
runs-on: | |
group: huge-runners | |
timeout-minutes: 40 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: E2E-testing-playwright | |
env: | |
INFRAHUB_DB_TYPE: neo4j | |
- name: E2E-testing-playwright-nats | |
env: | |
INFRAHUB_DB_TYPE: neo4j | |
INFRAHUB_USE_NATS: 1 | |
INFRAHUB_BROKER_DRIVER: nats | |
INFRAHUB_BROKER_PORT: 4222 | |
INFRAHUB_CACHE_DRIVER: nats | |
INFRAHUB_CACHE_ADDRESS: message-queue | |
INFRAHUB_CACHE_PORT: 4222 | |
name: ${{ matrix.name }} | |
env: ${{ matrix.env }} | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v4 | |
- name: Install NodeJS | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
- name: Install Invoke | |
run: pip install toml invoke | |
- name: Select infrahub port | |
run: echo "INFRAHUB_SERVER_PORT=$(shuf -n 1 -i 10000-30000)" >> $GITHUB_ENV | |
- name: Select infrahub db port | |
run: echo "INFRAHUB_DB_BACKUP_PORT=$(shuf -n 1 -i 10000-30000)" >> $GITHUB_ENV | |
- name: Select vmagent port | |
run: echo "VMAGENT_PORT=$(shuf -n 1 -i 10000-30000)" >> $GITHUB_ENV | |
- name: Set job name | |
run: echo JOB_NAME="$GITHUB_JOB" >> $GITHUB_ENV | |
- name: Enable tracing | |
if: github.event.pull_request.head.repo.fork == false | |
run: echo "INFRAHUB_TRACE_ENABLE=true" >> $GITHUB_ENV | |
- name: Set tracing configuration | |
run: echo "INFRAHUB_TRACE_INSECURE=false" >> $GITHUB_ENV | |
- name: Set tracing configuration | |
run: echo "INFRAHUB_TRACE_EXPORTER_TYPE=otlp" >> $GITHUB_ENV | |
- name: Set tracing configuration | |
run: echo "INFRAHUB_TRACE_EXPORTER_ENDPOINT=${{ secrets.TRACING_ENDPOINT }}" >> $GITHUB_ENV | |
- name: Set tracing configuration | |
run: echo "OTEL_RESOURCE_ATTRIBUTES=github.run_id=${GITHUB_RUN_ID}" >> $GITHUB_ENV | |
- name: "Store start time" | |
run: echo TEST_START_TIME=$(date +%s)000 >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }} >> $GITHUB_ENV | |
- name: "Clear docker environment" | |
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local | |
- name: Build Demo | |
run: invoke dev.build | |
- name: Pull External Docker Images | |
run: invoke dev.pull | |
- name: Initialize Demo | |
id: init-demo | |
run: invoke dev.start dev.load-infra-schema | |
- name: Check Demo Status | |
run: invoke dev.status | |
- name: Load Data | |
run: invoke dev.load-infra-data | |
- name: Git Repository | |
run: invoke dev.infra-git-import dev.infra-git-create | |
- name: Set infrahub address | |
run: echo "INFRAHUB_ADDRESS=http://localhost:${INFRAHUB_SERVER_PORT}" >> $GITHUB_ENV | |
- name: Install frontend dependencies | |
run: npm install | |
- name: Install Playwright Browsers | |
run: npx playwright install chromium | |
# Make chromium ignore netlink messages by returning HandleMessage early | |
- name: Chrome path | |
run: echo CHROME_BIN_PATH="$(npx playwright install chromium --dry-run | grep Install | awk '{print $3}')/chrome-linux/chrome" >> $GITHUB_ENV | |
- name: Chrome func offset | |
run: echo FUNC_OFFSET="$(objdump -C --file-offsets --disassemble='net::internal::AddressTrackerLinux::HandleMessage(char const*, int, bool*, bool*, bool*)' $CHROME_BIN_PATH | grep 'File Offset' | sed -n 1p | sed -E 's/.*File Offset. (.*)\).*/\1/')" >> $GITHUB_ENV | |
- name: Patch chromium | |
run: printf '\xc3' | dd of=$CHROME_BIN_PATH bs=1 seek=$(($FUNC_OFFSET)) conv=notrunc | |
- name: Wait for artifacts to be generated before restarting infrahub | |
if: needs.files-changed.outputs.e2e_tests == 'true' | |
run: npx playwright test artifact | |
- name: Add response delay if required | |
if: needs.files-changed.outputs.e2e_tests == 'true' | |
run: echo "INFRAHUB_MISC_RESPONSE_DELAY=2" >> $GITHUB_ENV && invoke dev.start | |
env: | |
INFRAHUB_MISC_RESPONSE_DELAY: 2 | |
- name: Run Playwright tests | |
run: npm run ci:test:e2e | |
- name: Generate tracing spans | |
if: always() && github.event.pull_request.head.repo.fork == false | |
uses: inception-health/otel-upload-test-artifact-action@v1 | |
with: | |
jobName: "E2E-testing-playwright" | |
stepName: "Run Playwright tests" | |
path: "frontend/app/playwright-junit.xml" | |
type: "junit" | |
githubToken: ${{ secrets.GH_TRACING_REPO_TOKEN }} | |
- name: playwright-report | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.name }} | |
path: frontend/app/playwright-report/ | |
- name: Containers after tests | |
if: always() | |
run: docker ps -a | |
- name: Display server logs | |
if: always() | |
run: docker logs "${INFRAHUB_BUILD_NAME}-infrahub-server-1" | |
- name: Display git 1 logs | |
if: always() | |
run: docker logs "${INFRAHUB_BUILD_NAME}-infrahub-git-1" | |
- name: Display git 2 logs | |
if: always() | |
run: docker logs "${INFRAHUB_BUILD_NAME}-infrahub-git-2" | |
- name: Display database logs | |
if: always() | |
run: docker logs "${INFRAHUB_BUILD_NAME}-database-1" | |
- name: Display message-queue logs | |
if: always() | |
run: docker logs "${INFRAHUB_BUILD_NAME}-message-queue-1" | |
- name: Display server status | |
if: always() | |
run: invoke demo.status | |
- name: "Clear docker environment and force vmagent to stop" | |
if: always() | |
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local | |
- name: "Wait for vmagent to push metrics" | |
if: always() | |
run: "sleep 10" | |
- name: "Show graph URL" | |
if: always() | |
run: 'echo "https://grafana-prod.tailc018d.ts.net/d/a4461039-bb27-4f57-9b2a-2c7f4e0a3459/e2e-tests?orgId=1&var-pr=$GITHUB_PR_NUMBER&var-job=$JOB_NAME&var-runner=$INFRAHUB_BUILD_NAME&from=$TEST_START_TIME&to=$(date +%s)000"' | |
# ------------------------------------------ Benchmarks ------------------------------------------------ | |
backend-benchmark: | |
needs: | |
- javascript-lint | |
- files-changed | |
- yaml-lint | |
- python-lint | |
if: | | |
always() && !cancelled() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
needs.files-changed.outputs.backend == 'true' | |
runs-on: | |
group: huge-runners | |
env: | |
INFRAHUB_DB_TYPE: memgraph | |
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: "Setup environment" | |
run: | | |
pipx install poetry | |
poetry config virtualenvs.prefer-active-python true | |
pip install invoke toml | |
- name: Set Version of Pydantic | |
run: poetry add pydantic@^2 | |
- name: "Install Package" | |
run: "poetry install" | |
- name: Select infrahub db port | |
run: echo "INFRAHUB_DB_PORT=$(shuf -n 1 -i 10000-30000)" >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }} >> $GITHUB_ENV | |
- name: "Set environment variables" | |
run: echo INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }} >> $GITHUB_ENV | |
- name: "Clear docker environment" | |
run: docker compose -p $INFRAHUB_BUILD_NAME down -v --remove-orphans --rmi local | |
- name: Create docker compose override | |
run: mv development/docker-compose.dev-override-benchmark.yml development/docker-compose.dev-override.yml | |
- name: Start dependencies | |
run: invoke dev.deps | |
- name: Update PATH | |
run: "echo ~/.cargo/bin >> $GITHUB_PATH" | |
- name: Run benchmarks | |
uses: CodSpeedHQ/action@v2 | |
with: | |
token: ${{ secrets.CODSPEED_TOKEN }} | |
run: "poetry run pytest -v backend/tests/benchmark/ --codspeed" | |
env: | |
INFRAHUB_TEST_IN_DOCKER: "false" | |
# ------------------------------------------ Coverall Report ------------------------------------------ | |
coverall-report: | |
needs: | |
- backend-tests-integration | |
- backend-tests-unit | |
- frontend-tests | |
- python-sdk-integration-tests | |
if: | | |
always() && !cancelled() | |
runs-on: ubuntu-latest | |
timeout-minutes: 10 | |
steps: | |
# # NOTE: The ref value should be different when triggered by pull_request event. | |
# # See: https://github.com/lewagon/wait-on-check-action/issues/25. | |
# - name: Wait on tests (PR) | |
# uses: lewagon/wait-on-check-action@e106e5c43e8ca1edea6383a39a01c5ca495fd812 | |
# if: github.event_name == 'pull_request' | |
# with: | |
# ref: ${{ github.event.pull_request.head.sha }} | |
# repo-token: ${{ secrets.GITHUB_TOKEN }} | |
# wait-interval: 10 | |
# running-workflow-name: report | |
# allowed-conclusions: success,skipped,cancelled,failure | |
# - name: Wait on tests (push) | |
# if: github.event_name != 'pull_request' | |
# uses: lewagon/wait-on-check-action@e106e5c43e8ca1edea6383a39a01c5ca495fd812 | |
# with: | |
# ref: ${{ github.sha }} | |
# repo-token: ${{ secrets.GITHUB_TOKEN }} | |
# wait-interval: 10 | |
# running-workflow-name: report | |
# allowed-conclusions: success,skipped,cancelled,failure | |
- uses: coverallsapp/github-action@v2 | |
continue-on-error: true | |
env: | |
COVERALLS_SERVICE_NUMBER: ${{ github.sha }} | |
with: | |
carryforward: "backend-unit,backend-integration,frontend-unit,python-sdk-unit,python-sdk-integration" | |
parallel-finished: true |