(new) CookResource will retry failed connections before returning (#609) #1514
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
# CI setup for Packrat | |
# | |
# Lints and Tests code for pull requests | |
# Builds after tests pass on push/merge to master or develop branch | |
name: CI | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
pull_request: | |
branches: | |
- master | |
- develop | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup node version | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.9.0 | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
- name: Install E2E dependencies | |
run: cd e2e && yarn install --frozen-lockfile && cd .. | |
- name: Check for lint errors | |
run: yarn lint | |
test: | |
runs-on: ubuntu-latest | |
services: | |
# MariaDB service for test database | |
mariadb: | |
image: mariadb:10.5 | |
env: | |
MYSQL_ROOT_PASSWORD: test | |
MYSQL_DATABASE: Packrat | |
ports: | |
- "3306:3306" | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10 | |
steps: | |
- name: verify Docker installation | |
run: docker compose version | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup test DB | |
run: mysql -h 127.0.0.1 -v -P 3306 -u root --password=test -e 'CREATE DATABASE IF NOT EXISTS Packrat' | |
- name: Setup test DB Schema | |
run: mysql -h 127.0.0.1 -v -P 3306 -u root --password=test --database=Packrat < server/db/sql/scripts/Packrat.SCHEMA.sql | |
- name: Setup test DB Proc | |
run: mysql -h 127.0.0.1 -v -P 3306 -u root --password=test --database=Packrat < server/db/sql/scripts/Packrat.PROC.sql | |
- name: Setup test DB Data | |
run: mysql -h 127.0.0.1 -v -P 3306 -u root --password=test --database=Packrat < server/db/sql/scripts/Packrat.DATA.sql | |
- name: Setup node version | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.9.0 | |
- name: Install git | |
run: sudo apt-add-repository ppa:git-core/ppa && sudo apt-get update && sudo apt-get install git | |
# Install dependencies in CI mode | |
- name: Install dependencies | |
run: yarn install --frozen-lockfile | |
# Install E2E dependencies in CI mode | |
- name: Install E2E dependencies | |
run: cd e2e && yarn install --frozen-lockfile && cd .. | |
# Run tests using test DB | |
- name: Run Tests | |
run: yarn test | |
env: | |
PACKRAT_EDAN_AUTH_KEY: ${{ secrets.PACKRAT_EDAN_AUTH_KEY }} | |
PACKRAT_DATABASE_URL: mysql://root:[email protected]:3306/Packrat | |
build: | |
# Only run this step on pull_request or push to specified branches (PR merge counts as push too) | |
if: ${{github.event_name == 'pull_request' || github.event_name == 'push'}} | |
runs-on: ubuntu-latest | |
needs: test | |
env: # Ideally this will be stored in github secrets and will be accessed via ${{ secrets.* }} | |
PACKRAT_PROXY_PORT: 80 | |
PACKRAT_CLIENT_PORT: 3000 | |
PACKRAT_SERVER_PORT: 4000 | |
PACKRAT_DB_PORT: 3306 | |
MYSQL_ROOT_PASSWORD: packrat | |
REACT_APP_PACKRAT_SERVER_ENDPOINT: http://packrat-server | |
PACKRAT_SOLR_PORT: 8983 | |
PACKRAT_SOLR_HOST: packrat-solr | |
steps: | |
- name: Verify Docker installation | |
run: docker compose version | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get current package version | |
id: packrat-version | |
uses: martinbeentjes/[email protected] | |
# Runs commands pre-build | |
# Ideally .env will be created from secrets ${{ secrets.DEV/PROD_ENV }} > .env | |
- name: Prepare build | |
run: touch .env.dev && touch .env.prod | |
- name: Build Dev images | |
if: ${{!contains(github.ref, 'master')}} | |
run: docker compose --env-file .env.dev -f ./conf/docker/docker-compose.dev.yml build | |
- name: Build Prod images | |
if: contains(github.ref, 'master') | |
run: docker compose --env-file .env.prod -f ./conf/docker/docker-compose.prod.yml build | |
# Prepares tag for docker images | |
- name: Prepare image tag | |
id: prepare-tag | |
if: ${{contains(github.ref, 'develop') || contains(github.ref, 'master')}} | |
run: | | |
if [ ${{ contains(github.ref, 'master') }} = true ]; then stage="prod"; else stage="dev"; fi | |
version=${{ steps.packrat-version.outputs.current-version }} | |
commit=${GITHUB_SHA:0:7} | |
echo "::set-output name=tag::$stage-$version-$commit" | |
# Tags images with "stage-env-version-commit-sha" eg. dev-1.0.0-abcd123 | |
- name: Tag images | |
if: ${{contains(github.ref, 'develop') || contains(github.ref, 'master')}} | |
run: | | |
echo Tagging with ${{ steps.prepare-tag.outputs.tag }} | |
docker tag packrat-server:latest packrat-server:${{ steps.prepare-tag.outputs.tag }} | |
docker tag packrat-client:latest packrat-client:${{ steps.prepare-tag.outputs.tag }} | |
docker tag packrat-proxy:latest packrat-proxy:${{ steps.prepare-tag.outputs.tag }} | |
# Runs commands post-build | |
- name: Build cleanup | |
if: ${{contains(github.ref, 'develop') || contains(github.ref, 'master')}} | |
run: | | |
echo Cleaning up redundant tags | |
docker rmi packrat-server:latest packrat-client:latest packrat-proxy:latest | |
docker images | |
# Pushes built images to container registry | |
- name: Push images | |
if: ${{contains(github.ref, 'develop') || contains(github.ref, 'master')}} | |
run: echo Pushing images to container registry... |