added test for quickstart guide w/ burnettk

This commit is contained in:
jasquat 2023-02-16 15:05:55 -05:00
parent c389283eb6
commit 0839214fa5
6 changed files with 508 additions and 472 deletions

View File

@ -1,353 +1,353 @@
name: Backend Tests # name: Backend Tests
#
on: # on:
- push # - push
- pull_request # - pull_request
#
defaults: # defaults:
run: # run:
working-directory: spiffworkflow-backend # working-directory: spiffworkflow-backend
#
jobs: # jobs:
tests: # tests:
name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }} ${{ matrix.database }} # name: ${{ matrix.session }} ${{ matrix.python }} / ${{ matrix.os }} ${{ matrix.database }}
runs-on: ${{ matrix.os }} # runs-on: ${{ matrix.os }}
strategy: # strategy:
fail-fast: false # fail-fast: false
matrix: # matrix:
include: # include:
# FIXME: https://github.com/mysql/mysql-connector-python/pull/86 # # FIXME: https://github.com/mysql/mysql-connector-python/pull/86
# put back when poetry update protobuf mysql-connector-python updates protobuf # # put back when poetry update protobuf mysql-connector-python updates protobuf
# right now mysql is forcing protobuf to version 3 # # right now mysql is forcing protobuf to version 3
# - { python: "3.11", os: "ubuntu-latest", session: "safety" } # # - { python: "3.11", os: "ubuntu-latest", session: "safety" }
- { python: "3.11", os: "ubuntu-latest", session: "mypy" } # - { python: "3.11", os: "ubuntu-latest", session: "mypy" }
- { python: "3.10", os: "ubuntu-latest", session: "mypy" } # - { python: "3.10", os: "ubuntu-latest", session: "mypy" }
- { python: "3.9", os: "ubuntu-latest", session: "mypy" } # - { python: "3.9", os: "ubuntu-latest", session: "mypy" }
- { # - {
python: "3.11", # python: "3.11",
os: "ubuntu-latest", # os: "ubuntu-latest",
session: "tests", # session: "tests",
database: "mysql", # database: "mysql",
} # }
- { # - {
python: "3.11", # python: "3.11",
os: "ubuntu-latest", # os: "ubuntu-latest",
session: "tests", # session: "tests",
database: "postgres", # database: "postgres",
} # }
- { # - {
python: "3.11", # python: "3.11",
os: "ubuntu-latest", # os: "ubuntu-latest",
session: "tests", # session: "tests",
database: "sqlite", # database: "sqlite",
} # }
- { # - {
python: "3.10", # python: "3.10",
os: "ubuntu-latest", # os: "ubuntu-latest",
session: "tests", # session: "tests",
database: "sqlite", # database: "sqlite",
} # }
- { # - {
python: "3.9", # python: "3.9",
os: "ubuntu-latest", # os: "ubuntu-latest",
session: "tests", # session: "tests",
database: "sqlite", # database: "sqlite",
} # }
- { # - {
python: "3.10", # python: "3.10",
os: "windows-latest", # os: "windows-latest",
session: "tests", # session: "tests",
database: "sqlite", # database: "sqlite",
} # }
- { # - {
python: "3.11", # python: "3.11",
os: "macos-latest", # os: "macos-latest",
session: "tests", # session: "tests",
database: "sqlite", # database: "sqlite",
} # }
- { # - {
# typeguard 2.13.3 is broken with TypeDict in 3.11. # # typeguard 2.13.3 is broken with TypeDict in 3.11.
# probably the next release fixes it. # # probably the next release fixes it.
# https://github.com/agronholm/typeguard/issues/242 # # https://github.com/agronholm/typeguard/issues/242
python: "3.11", # python: "3.11",
os: "ubuntu-latest", # os: "ubuntu-latest",
session: "typeguard", # session: "typeguard",
database: "sqlite", # database: "sqlite",
} # }
- { python: "3.11", os: "ubuntu-latest", session: "xdoctest" } # - { python: "3.11", os: "ubuntu-latest", session: "xdoctest" }
- { python: "3.11", os: "ubuntu-latest", session: "docs-build" } # - { python: "3.11", os: "ubuntu-latest", session: "docs-build" }
#
env: # env:
FLASK_SESSION_SECRET_KEY: super_secret_key # FLASK_SESSION_SECRET_KEY: super_secret_key
FORCE_COLOR: "1" # FORCE_COLOR: "1"
NOXSESSION: ${{ matrix.session }} # NOXSESSION: ${{ matrix.session }}
PRE_COMMIT_COLOR: "always" # PRE_COMMIT_COLOR: "always"
SPIFFWORKFLOW_BACKEND_DATABASE_PASSWORD: password # SPIFFWORKFLOW_BACKEND_DATABASE_PASSWORD: password
SPIFFWORKFLOW_BACKEND_DATABASE_TYPE: ${{ matrix.database }} # SPIFFWORKFLOW_BACKEND_DATABASE_TYPE: ${{ matrix.database }}
#
steps: # steps:
- name: Check out the repository # - name: Check out the repository
uses: actions/checkout@v3.0.2 # uses: actions/checkout@v3.0.2
#
- name: Set up Python ${{ matrix.python }} # - name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4.2.0 # uses: actions/setup-python@v4.2.0
with: # with:
python-version: ${{ matrix.python }} # python-version: ${{ matrix.python }}
#
- name: Upgrade pip # - name: Upgrade pip
run: | # run: |
pip install --constraint=.github/workflows/constraints.txt pip # pip install --constraint=.github/workflows/constraints.txt pip
pip --version # pip --version
#
- name: Upgrade pip in virtual environments # - name: Upgrade pip in virtual environments
shell: python
run: |
import os
import pip
with open(os.environ["GITHUB_ENV"], mode="a") as io:
print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
- name: Install Poetry
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
poetry --version
- name: Install Nox
run: |
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
nox --version
# - name: Compute pre-commit cache key
# if: matrix.session == 'pre-commit'
# id: pre-commit-cache
# shell: python # shell: python
# run: | # run: |
# import hashlib # import os
# import sys # import pip
# #
# python = "py{}.{}".format(*sys.version_info[:2]) # with open(os.environ["GITHUB_ENV"], mode="a") as io:
# payload = sys.version.encode() + sys.executable.encode() # print(f"VIRTUALENV_PIP={pip.__version__}", file=io)
# digest = hashlib.sha256(payload).hexdigest()
# result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
# #
# print("::set-output name=result::{}".format(result)) # - name: Install Poetry
# run: |
# pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
# poetry --version
# #
# - name: Restore pre-commit cache # - name: Install Nox
# uses: actions/cache@v3.0.11 # run: |
# if: matrix.session == 'pre-commit' # pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
# pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
# nox --version
#
# # - name: Compute pre-commit cache key
# # if: matrix.session == 'pre-commit'
# # id: pre-commit-cache
# # shell: python
# # run: |
# # import hashlib
# # import sys
# #
# # python = "py{}.{}".format(*sys.version_info[:2])
# # payload = sys.version.encode() + sys.executable.encode()
# # digest = hashlib.sha256(payload).hexdigest()
# # result = "${{ runner.os }}-{}-{}-pre-commit".format(python, digest[:8])
# #
# # print("::set-output name=result::{}".format(result))
# #
# # - name: Restore pre-commit cache
# # uses: actions/cache@v3.0.11
# # if: matrix.session == 'pre-commit'
# # with:
# # path: ~/.cache/pre-commit
# # key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }}
# # restore-keys: |
# # ${{ steps.pre-commit-cache.outputs.result }}-
# - name: Setup Mysql
# uses: mirromutth/mysql-action@v1.1
# with: # with:
# path: ~/.cache/pre-commit # host port: 3306
# key: ${{ steps.pre-commit-cache.outputs.result }}-${{ hashFiles('.pre-commit-config.yaml') }} # container port: 3306
# restore-keys: | # mysql version: "8.0"
# ${{ steps.pre-commit-cache.outputs.result }}- # mysql database: "spiffworkflow_backend_unit_testing"
- name: Setup Mysql # mysql root password: password
uses: mirromutth/mysql-action@v1.1 # if: matrix.database == 'mysql'
with: #
host port: 3306 # - name: Setup Postgres
container port: 3306 # run: docker run --name postgres-spiff -p 5432:5432 -e POSTGRES_PASSWORD=spiffworkflow_backend -e POSTGRES_USER=spiffworkflow_backend -e POSTGRES_DB=spiffworkflow_backend_unit_testing -d postgres
mysql version: "8.0" # if: matrix.database == 'postgres'
mysql database: "spiffworkflow_backend_unit_testing" #
mysql root password: password # - name: Run Nox
if: matrix.database == 'mysql' # run: |
# nox --force-color --python=${{ matrix.python }}
- name: Setup Postgres #
run: docker run --name postgres-spiff -p 5432:5432 -e POSTGRES_PASSWORD=spiffworkflow_backend -e POSTGRES_USER=spiffworkflow_backend -e POSTGRES_DB=spiffworkflow_backend_unit_testing -d postgres # - name: Upload coverage data
if: matrix.database == 'postgres' # # pin to upload coverage from only one matrix entry, otherwise coverage gets confused later
# if: always() && matrix.session == 'tests' && matrix.python == '3.11' && matrix.os == 'ubuntu-latest' && matrix.database == 'mysql'
- name: Run Nox # uses: "actions/upload-artifact@v3.0.0"
run: | # # this action doesn't seem to respect working-directory so include working-directory value in path
nox --force-color --python=${{ matrix.python }} # with:
# name: coverage-data
- name: Upload coverage data # path: "spiffworkflow-backend/.coverage.*"
# pin to upload coverage from only one matrix entry, otherwise coverage gets confused later #
if: always() && matrix.session == 'tests' && matrix.python == '3.11' && matrix.os == 'ubuntu-latest' && matrix.database == 'mysql' # - name: Upload documentation
uses: "actions/upload-artifact@v3.0.0" # if: matrix.session == 'docs-build'
# this action doesn't seem to respect working-directory so include working-directory value in path # uses: actions/upload-artifact@v3.0.0
with: # with:
name: coverage-data # name: docs
path: "spiffworkflow-backend/.coverage.*" # path: docs/_build
#
- name: Upload documentation # - name: Upload logs
if: matrix.session == 'docs-build' # if: failure() && matrix.session == 'tests'
uses: actions/upload-artifact@v3.0.0 # uses: "actions/upload-artifact@v3.0.0"
with: # with:
name: docs # name: logs-${{matrix.python}}-${{matrix.os}}-${{matrix.database}}
path: docs/_build # path: "./log/*.log"
#
- name: Upload logs # run_pre_commit_checks:
if: failure() && matrix.session == 'tests' # runs-on: ubuntu-latest
uses: "actions/upload-artifact@v3.0.0" # defaults:
with: # run:
name: logs-${{matrix.python}}-${{matrix.os}}-${{matrix.database}} # working-directory: .
path: "./log/*.log" # steps:
# - name: Check out the repository
run_pre_commit_checks: # uses: actions/checkout@v3.0.2
runs-on: ubuntu-latest # with:
defaults: # # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud
run: # fetch-depth: 0
working-directory: . # - name: Set up Python
steps: # uses: actions/setup-python@v4.2.0
- name: Check out the repository # with:
uses: actions/checkout@v3.0.2 # python-version: "3.11"
with: # - name: Install Poetry
# Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud # run: |
fetch-depth: 0 # pipx install poetry
- name: Set up Python # poetry --version
uses: actions/setup-python@v4.2.0 # - name: Poetry Install
with: # run: poetry install
python-version: "3.11" # - name: run_pre_commit
- name: Install Poetry # run: ./bin/run_pre_commit_in_ci
run: | #
pipx install poetry # check_docker_start_script:
poetry --version # runs-on: ubuntu-latest
- name: Poetry Install # steps:
run: poetry install # - name: Check out the repository
- name: run_pre_commit # uses: actions/checkout@v3.0.2
run: ./bin/run_pre_commit_in_ci # with:
# # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud
check_docker_start_script: # fetch-depth: 0
runs-on: ubuntu-latest # - name: Checkout Samples
steps: # uses: actions/checkout@v3
- name: Check out the repository # with:
uses: actions/checkout@v3.0.2 # repository: sartography/sample-process-models
with: # path: sample-process-models
# Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud # - name: start_backend
fetch-depth: 0 # run: ./bin/build_and_run_with_docker_compose
- name: Checkout Samples # timeout-minutes: 20
uses: actions/checkout@v3 # env:
with: # SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP: "false"
repository: sartography/sample-process-models # - name: wait_for_backend
path: sample-process-models # run: ./bin/wait_for_server_to_be_up 5
- name: start_backend #
run: ./bin/build_and_run_with_docker_compose # coverage:
timeout-minutes: 20 # runs-on: ubuntu-latest
env: # needs: [tests, run_pre_commit_checks, check_docker_start_script]
SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP: "false" # steps:
- name: wait_for_backend # - name: Check out the repository
run: ./bin/wait_for_server_to_be_up 5 # uses: actions/checkout@v3.0.2
# with:
coverage: # # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud
runs-on: ubuntu-latest # fetch-depth: 0
needs: [tests, run_pre_commit_checks, check_docker_start_script] #
steps: # - name: Set up Python
- name: Check out the repository # uses: actions/setup-python@v4.2.0
uses: actions/checkout@v3.0.2 # with:
with: # python-version: "3.11"
# Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud #
fetch-depth: 0 # - name: Upgrade pip
# run: |
- name: Set up Python # pip install --constraint=.github/workflows/constraints.txt pip
uses: actions/setup-python@v4.2.0 # pip --version
with: #
python-version: "3.11" # - name: Install Poetry
# run: |
- name: Upgrade pip # pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry
run: | # poetry --version
pip install --constraint=.github/workflows/constraints.txt pip #
pip --version # - name: Install Nox
# run: |
- name: Install Poetry # pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox
run: | # pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry
pipx install --pip-args=--constraint=.github/workflows/constraints.txt poetry # nox --version
poetry --version #
# - name: Download coverage data
- name: Install Nox # uses: actions/download-artifact@v3.0.1
run: | # with:
pipx install --pip-args=--constraint=.github/workflows/constraints.txt nox # name: coverage-data
pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry # # this action doesn't seem to respect working-directory so include working-directory value in path
nox --version # path: spiffworkflow-backend
#
- name: Download coverage data # - name: Combine coverage data and display human readable report
uses: actions/download-artifact@v3.0.1 # run: |
with: # find . -name \*.pyc -delete
name: coverage-data # nox --force-color --session=coverage
# this action doesn't seem to respect working-directory so include working-directory value in path #
path: spiffworkflow-backend # - name: Create coverage report
# run: |
- name: Combine coverage data and display human readable report # nox --force-color --session=coverage -- xml
run: | #
find . -name \*.pyc -delete # - name: Upload coverage report
nox --force-color --session=coverage # uses: codecov/codecov-action@v3.1.0
#
- name: Create coverage report # - name: SonarCloud Scan
run: | # uses: sonarsource/sonarcloud-github-action@master
nox --force-color --session=coverage -- xml # # thought about just skipping dependabot
# # if: ${{ github.actor != 'dependabot[bot]' }}
- name: Upload coverage report # # but figured all pull requests seems better, since none of them will have access to sonarcloud.
uses: codecov/codecov-action@v3.1.0 # # however, with just skipping pull requests, the build associated with "Triggered via push" is also associated with the pull request and also fails hitting sonarcloud
# # if: ${{ github.event_name != 'pull_request' }}
- name: SonarCloud Scan # # so just skip everything but main
uses: sonarsource/sonarcloud-github-action@master # if: github.ref_name == 'main'
# thought about just skipping dependabot # with:
# if: ${{ github.actor != 'dependabot[bot]' }} # projectBaseDir: spiffworkflow-frontend
# but figured all pull requests seems better, since none of them will have access to sonarcloud. # env:
# however, with just skipping pull requests, the build associated with "Triggered via push" is also associated with the pull request and also fails hitting sonarcloud # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if: ${{ github.event_name != 'pull_request' }} # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# so just skip everything but main # # part about saving PR number and then using it from auto-merge-dependabot-prs from:
if: github.ref_name == 'main' # # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
with: # - name: Save PR number
projectBaseDir: spiffworkflow-frontend # if: ${{ github.event_name == 'pull_request' }}
env: # env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # PR_NUMBER: ${{ github.event.number }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # run: |
# part about saving PR number and then using it from auto-merge-dependabot-prs from: # mkdir -p ./pr
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run # echo "$PR_NUMBER" > ./pr/pr_number
- name: Save PR number # - uses: actions/upload-artifact@v3
if: ${{ github.event_name == 'pull_request' }} # with:
env: # name: pr_number
PR_NUMBER: ${{ github.event.number }} # path: pr/
run: | #
mkdir -p ./pr # build-and-push-image:
echo "$PR_NUMBER" > ./pr/pr_number # needs: coverage
- uses: actions/upload-artifact@v3 # if: ${{ github.ref_name == 'main' && github.event_name == 'push' }}
with: # env:
name: pr_number # REGISTRY: ghcr.io
path: pr/ # IMAGE_NAME: sartography/spiffworkflow-backend
# runs-on: ubuntu-latest
build-and-push-image: # permissions:
needs: coverage # contents: read
if: ${{ github.ref_name == 'main' && github.event_name == 'push' }} # packages: write
env: #
REGISTRY: ghcr.io # steps:
IMAGE_NAME: sartography/spiffworkflow-backend # - name: Check out the repository
runs-on: ubuntu-latest # uses: actions/checkout@v3.0.2
permissions: # with:
contents: read # # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud
packages: write # fetch-depth: 0
# - name: Get current date
steps: # id: date
- name: Check out the repository # run: echo "date=$(date +%s)" >> $GITHUB_OUTPUT
uses: actions/checkout@v3.0.2 # - name: Log in to the Container registry
with: # uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
# Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud # with:
fetch-depth: 0 # registry: ${{ env.REGISTRY }}
- name: Get current date # username: ${{ github.actor }}
id: date # password: ${{ secrets.GITHUB_TOKEN }}
run: echo "date=$(date +%s)" >> $GITHUB_OUTPUT #
- name: Log in to the Container registry # - name: Extract metadata (tags, labels) for Docker
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 # id: meta
with: # uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
registry: ${{ env.REGISTRY }} # with:
username: ${{ github.actor }} # images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
password: ${{ secrets.GITHUB_TOKEN }} #
# - name: Build and push Docker image
- name: Extract metadata (tags, labels) for Docker # uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
id: meta # env:
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 # # if we ever support more than main we will need to format the ref name
with: # # like sub '/' with '-'
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} # TAG: ${{ github.ref_name }}-${{ steps.date.outputs.date }}
# with:
- name: Build and push Docker image # # this action doesn't seem to respect working-directory so set context
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc # context: spiffworkflow-backend
env: # push: true
# if we ever support more than main we will need to format the ref name # tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
# like sub '/' with '-' # labels: ${{ steps.meta.outputs.labels }}
TAG: ${{ github.ref_name }}-${{ steps.date.outputs.date }}
with:
# this action doesn't seem to respect working-directory so set context
context: spiffworkflow-backend
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
labels: ${{ steps.meta.outputs.labels }}

View File

@ -4,126 +4,154 @@ on:
- push - push
- pull_request - pull_request
defaults: # defaults:
run: # run:
working-directory: spiffworkflow-frontend # working-directory: spiffworkflow-frontend
# https://docs.github.com/en/actions/using-workflows/reusing-workflows # https://docs.github.com/en/actions/using-workflows/reusing-workflows
jobs: jobs:
tests: quickstart-guide-test:
runs-on: ubuntu-latest runs-on: ubuntu:latest
steps:
- name: Development Code
uses: actions/checkout@v3
with:
# Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- run: npm install
- run: npm run lint
- run: npm test
- run: npm run build --if-present
- name: SonarCloud Scan
# thought about just skipping dependabot
# if: ${{ github.actor != 'dependabot[bot]' }}
# but figured all pull requests seems better, since none of them will have access to sonarcloud.
# however, with just skipping pull requests, the build associated with "Triggered via push" is also associated with the pull request and also fails hitting sonarcloud
# if: ${{ github.event_name != 'pull_request' }}
# so just skip everything but main
if: github.ref_name == 'main'
uses: sonarsource/sonarcloud-github-action@master
with:
projectBaseDir: spiffworkflow-frontend
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# part about saving PR number and then using it from auto-merge-dependabot-prs from:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
- name: Save PR number
if: ${{ github.event_name == 'pull_request' }}
env:
PR_NUMBER: ${{ github.event.number }}
run: |
mkdir -p ./pr
echo "$PR_NUMBER" > ./pr/pr_number
- uses: actions/upload-artifact@v3
with:
name: pr_number
path: pr/
cypress-run:
runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Checkout Samples - name: Setup Apps
uses: actions/checkout@v3 run: ./bin/run_arena_with_docker_compose
with:
repository: sartography/sample-process-models
path: sample-process-models
- name: start_keycloak
working-directory: ./spiffworkflow-backend
run: ./keycloak/bin/start_keycloak
- name: start_backend
working-directory: ./spiffworkflow-backend
run: ./bin/build_and_run_with_docker_compose
timeout-minutes: 20
env:
SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA: "true"
SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME: "acceptance_tests.yml"
- name: start_frontend
# working-directory: ./spiffworkflow-frontend
run: ./bin/build_and_run_with_docker_compose
- name: wait_for_backend - name: wait_for_backend
working-directory: ./spiffworkflow-backend working-directory: ./spiffworkflow-backend
run: ./bin/wait_for_server_to_be_up 5 run: ./bin/wait_for_server_to_be_up 5 8000
- name: wait_for_frontend - name: wait_for_frontend
# working-directory: ./spiffworkflow-frontend working-directory: ./spiffworkflow-frontend
run: ./bin/wait_for_frontend_to_be_up 5 run: ./bin/wait_for_frontend_to_be_up 5 8001
- name: wait_for_keycloak - name: wait_for_keycloak
working-directory: ./spiffworkflow-backend working-directory: ./spiffworkflow-backend
run: ./keycloak/bin/wait_for_keycloak 5 run: ./keycloak/bin/wait_for_keycloak 5 8002
- name: Cypress run - name: Cypress run
uses: cypress-io/github-action@v4 uses: cypress-io/github-action@v4
with: with:
working-directory: ./spiffworkflow-frontend working-directory: ./spiffworkflow-frontend
browser: chrome browser: chrome
# only record on push, not pull_request, since we do not have secrets for PRs,
# so the required CYPRESS_RECORD_KEY will not be available.
# we have limited runs in cypress cloud, so only record main builds
record: ${{ github.ref_name == 'main' && github.event_name == 'push' }}
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build # pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK: "true" CYPRESS_SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK: "false"
- name: get_backend_logs_from_docker_compose CYPRESS_SPIFFWORKFLOW_FRONTEND_USERNAME: "admin"
if: failure() CYPRESS_SPIFFWORKFLOW_FRONTEND_PASSWORD: "admin"
working-directory: ./spiffworkflow-backend SPIFFWORKFLOW_FRONTEND_PORT: 8001
run: ./bin/get_logs_from_docker_compose >./log/docker_compose.log
- name: Upload logs
if: failure()
uses: "actions/upload-artifact@v3.0.0"
with:
name: spiffworkflow-backend-logs
path: "./spiffworkflow-backend/log/*.log"
# https://github.com/cypress-io/github-action#artifacts # tests:
- name: upload_screenshots # runs-on: ubuntu-latest
uses: actions/upload-artifact@v2 # steps:
if: failure() # - name: Development Code
with: # uses: actions/checkout@v3
name: cypress-screenshots # with:
path: ./spiffworkflow-frontend/cypress/screenshots # # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud
# Test run video was always captured, so this action uses "always()" condition # fetch-depth: 0
- name: upload_videos # - name: Setup Node
uses: actions/upload-artifact@v2 # uses: actions/setup-node@v3
if: failure() # with:
with: # node-version: 18.x
name: cypress-videos # - run: npm install
path: ./spiffworkflow-frontend/cypress/videos # - run: npm run lint
# - run: npm test
# - run: npm run build --if-present
# - name: SonarCloud Scan
# # thought about just skipping dependabot
# # if: ${{ github.actor != 'dependabot[bot]' }}
# # but figured all pull requests seems better, since none of them will have access to sonarcloud.
# # however, with just skipping pull requests, the build associated with "Triggered via push" is also associated with the pull request and also fails hitting sonarcloud
# # if: ${{ github.event_name != 'pull_request' }}
# # so just skip everything but main
# if: github.ref_name == 'main'
# uses: sonarsource/sonarcloud-github-action@master
# with:
# projectBaseDir: spiffworkflow-frontend
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# # part about saving PR number and then using it from auto-merge-dependabot-prs from:
# # https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
# - name: Save PR number
# if: ${{ github.event_name == 'pull_request' }}
# env:
# PR_NUMBER: ${{ github.event.number }}
# run: |
# mkdir -p ./pr
# echo "$PR_NUMBER" > ./pr/pr_number
# - uses: actions/upload-artifact@v3
# with:
# name: pr_number
# path: pr/
#
# cypress-run:
# runs-on: ubuntu-20.04
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Checkout Samples
# uses: actions/checkout@v3
# with:
# repository: sartography/sample-process-models
# path: sample-process-models
# - name: start_keycloak
# working-directory: ./spiffworkflow-backend
# run: ./keycloak/bin/start_keycloak
# - name: start_backend
# working-directory: ./spiffworkflow-backend
# run: ./bin/build_and_run_with_docker_compose
# timeout-minutes: 20
# env:
# SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA: "true"
# SPIFFWORKFLOW_BACKEND_PERMISSIONS_FILE_NAME: "acceptance_tests.yml"
# - name: start_frontend
# # working-directory: ./spiffworkflow-frontend
# run: ./bin/build_and_run_with_docker_compose
# - name: wait_for_backend
# working-directory: ./spiffworkflow-backend
# run: ./bin/wait_for_server_to_be_up 5
# - name: wait_for_frontend
# # working-directory: ./spiffworkflow-frontend
# run: ./bin/wait_for_frontend_to_be_up 5
# - name: wait_for_keycloak
# working-directory: ./spiffworkflow-backend
# run: ./keycloak/bin/wait_for_keycloak 5
# - name: Cypress run
# uses: cypress-io/github-action@v4
# with:
# working-directory: ./spiffworkflow-frontend
# browser: chrome
# # only record on push, not pull_request, since we do not have secrets for PRs,
# # so the required CYPRESS_RECORD_KEY will not be available.
# # we have limited runs in cypress cloud, so only record main builds
# record: ${{ github.ref_name == 'main' && github.event_name == 'push' }}
# env:
# # pass the Dashboard record key as an environment variable
# CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# # pass GitHub token to allow accurately detecting a build vs a re-run build
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# CYPRESS_SPIFFWORKFLOW_FRONTEND_AUTH_WITH_KEYCLOAK: "true"
# - name: get_backend_logs_from_docker_compose
# if: failure()
# working-directory: ./spiffworkflow-backend
# run: ./bin/get_logs_from_docker_compose >./log/docker_compose.log
# - name: Upload logs
# if: failure()
# uses: "actions/upload-artifact@v3.0.0"
# with:
# name: spiffworkflow-backend-logs
# path: "./spiffworkflow-backend/log/*.log"
#
# # https://github.com/cypress-io/github-action#artifacts
# - name: upload_screenshots
# uses: actions/upload-artifact@v2
# if: failure()
# with:
# name: cypress-screenshots
# path: ./spiffworkflow-frontend/cypress/screenshots
# # Test run video was always captured, so this action uses "always()" condition
# - name: upload_videos
# uses: actions/upload-artifact@v2
# if: failure()
# with:
# name: cypress-videos
# path: ./spiffworkflow-frontend/cypress/videos

View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
mkdir -p spiffworkflow
cd spiffworkflow
wget https://raw.githubusercontent.com/sartography/spiff-arena/main/docker-compose.yml
docker compose pull
docker compose up -d

View File

@ -7,14 +7,12 @@ function error_handler() {
trap 'error_handler ${LINENO} $?' ERR trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail set -o errtrace -o errexit -o nounset -o pipefail
max_attempts="${1:-}" max_attempts="${1:-100}"
if [[ -z "$max_attempts" ]]; then port="${2:-7000}"
max_attempts=100
fi
echo "waiting for backend to come up..." echo "waiting for backend to come up..."
attempts=0 attempts=0
while [[ "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:7000/v1.0/status)" != "200" ]]; do while [[ "$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:${port}/v1.0/status")" != "200" ]]; do
if [[ "$attempts" -gt "$max_attempts" ]]; then if [[ "$attempts" -gt "$max_attempts" ]]; then
>&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem" >&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem"
exit 1 exit 1

View File

@ -7,14 +7,12 @@ function error_handler() {
trap 'error_handler ${LINENO} $?' ERR trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail set -o errtrace -o errexit -o nounset -o pipefail
max_attempts="${1:-}" max_attempts="${1:-100}"
if [[ -z "$max_attempts" ]]; then port="${2:-7002}"
max_attempts=100
fi
echo "waiting for backend to come up..." echo "waiting for backend to come up..."
attempts=0 attempts=0
while [[ "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:7002/realms/master/.well-known/openid-configuration)" != "200" ]]; do while [[ "$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:${port}/realms/master/.well-known/openid-configuration")" != "200" ]]; do
if [[ "$attempts" -gt "$max_attempts" ]]; then if [[ "$attempts" -gt "$max_attempts" ]]; then
>&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem" >&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem"
exit 1 exit 1

View File

@ -7,14 +7,12 @@ function error_handler() {
trap 'error_handler ${LINENO} $?' ERR trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail set -o errtrace -o errexit -o nounset -o pipefail
max_attempts="${1:-}" max_attempts="${1:-100}"
if [[ -z "$max_attempts" ]]; then port="${2:-7001}"
max_attempts=100
fi
echo "waiting for backend to come up..." echo "waiting for frontend to come up..."
attempts=0 attempts=0
while [[ "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:7001)" != "200" ]]; do while [[ "$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:${port}")" != "200" ]]; do
if [[ "$attempts" -gt "$max_attempts" ]]; then if [[ "$attempts" -gt "$max_attempts" ]]; then
>&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem" >&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem"
exit 1 exit 1