mirror of
https://github.com/sartography/spiffworkflow-frontend.git
synced 2025-02-22 11:18:19 +00:00
attempt to wait for backend and frontend to be up w/ burnettk
This commit is contained in:
parent
edf6293d33
commit
5d2ffa3111
21
.github/workflows/tests.yml
vendored
21
.github/workflows/tests.yml
vendored
@ -51,9 +51,26 @@ jobs:
|
||||
- name: start_frontend
|
||||
working-directory: ./spiffworkflow-frontend
|
||||
run: ./bin/build_and_run_with_docker_compose
|
||||
# Install NPM dependencies, cache them correctly
|
||||
# and run all Cypress tests
|
||||
- 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: Cypress run
|
||||
uses: cypress-io/github-action@v4
|
||||
with:
|
||||
working-directory: ./spiffworkflow-frontend
|
||||
|
||||
# https://github.com/cypress-io/github-action#artifacts
|
||||
- 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
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: always()
|
||||
with:
|
||||
name: cypress-videos
|
||||
path: ./spiffworkflow-frontend/cypress/videos
|
||||
|
24
bin/wait_for_frontend_to_be_up
Executable file
24
bin/wait_for_frontend_to_be_up
Executable file
@ -0,0 +1,24 @@
|
||||
#!/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
|
||||
|
||||
max_attempts="${1:-}"
|
||||
if [[ -z "$max_attempts" ]]; then
|
||||
max_attempts=100
|
||||
fi
|
||||
|
||||
echo "waiting for backend to come up..."
|
||||
attempts=0
|
||||
while [[ "$(curl -s -o /dev/null -w '%{http_code}' http://localhost:7001)" != "200" ]]; do
|
||||
if [[ "$attempts" -gt "$max_attempts" ]]; then
|
||||
>&2 echo "ERROR: Server not up after $max_attempts attempts. There is probably a problem"
|
||||
exit 1
|
||||
fi
|
||||
attempts=$(( attempts + 1 ))
|
||||
sleep 1
|
||||
done
|
@ -30,7 +30,7 @@
|
||||
"scripts": {
|
||||
"start": "PORT=7001 craco start",
|
||||
"build": "craco build",
|
||||
"test": "craco test",
|
||||
"test": "react-scripts test",
|
||||
"eject": "craco eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
|
Loading…
x
Reference in New Issue
Block a user