Skip to content

Commit

Permalink
Make all the ifs in e2e and deploy easier to maintain, speed up lin…
Browse files Browse the repository at this point in the history
…t web (#653)

* Add a step to clean up `if`s in e2e and deploy

* Cache yarn in lint

* e2e should run if cypress tests get updated
  • Loading branch information
rblaine95 authored Mar 28, 2024
1 parent 4545705 commit 4a9aeff
Showing 1 changed file with 47 additions and 93 deletions.
140 changes: 47 additions & 93 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,18 @@ jobs:
filters: |-
changes:
- '${{ matrix.dir }}/**'
web:
- './src/web/**'
- uses: actions/setup-node@v4
if: (steps.filter.outputs.web == 'true' || github.event_name == 'workflow_dispatch') && matrix.lang == 'js'
if: (steps.filter.outputs.changes == 'true' || github.event_name == 'workflow_dispatch') && matrix.lang == 'js'
with:
node-version: 18
cache: yarn
cache-dependency-path: ${{ matrix.dir }}/yarn.lock
- uses: actions/cache@v4
if: (steps.filter.outputs.changes == 'true' || github.event_name == 'workflow_dispatch') && matrix.lang == 'js'
with:
path: ${{ matrix.dir }}/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- run: yarn install --frozen-lockfile
if: (steps.filter.outputs.changes == 'true' || github.event_name == 'workflow_dispatch') && matrix.lang == 'js'
working-directory: ${{ matrix.dir }}
Expand Down Expand Up @@ -210,24 +214,28 @@ jobs:
- './src/web/**'
keycloak:
- './src/keycloak/**'
cypress:
- './cypress/**'
- name: Should e2e run?
id: should-run
run: |-
if [ "${{ steps.filter.outputs.api }}" = "true" ] || \
[ "${{ steps.filter.outputs.web }}" = "true" ] || \
[ "${{ steps.filter.outputs.keycloak }}" = "true" ] || \
[ "${{ steps.filter.outputs.cypress }}" = "true" ] || \
[ "${{ github.event_name == 'workflow_dispatch' }}" = "true" ]; then
echo run=true >> $GITHUB_OUTPUT
else
echo run=false >> $GITHUB_OUTPUT
fi
- uses: docker/login-action@v3
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Create env file
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
run: |
echo "AWSS3__Buckets__Public__AccessKey=${{ secrets.PUBLIC_S3_ACCESS_KEY }}" >> src/api/env.secrets
echo "AWSS3__Buckets__Public__SecretKey=${{ secrets.PUBLIC_S3_SECRET_KEY }}" >> src/api/env.secrets
Expand All @@ -248,12 +256,7 @@ jobs:
echo "AppSettings__SSISchemaFullNameYoID=${{ secrets.APPSETTINGS_SSISCHEMAFULLNAMEYOID }}" >> src/api/env.secrets
- name: Pre-pull images
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
run: |-
docker compose -f ./src/api/docker-compose.yml pull
docker compose -f ./src/web/docker-compose.yml pull
Expand All @@ -262,12 +265,7 @@ jobs:
YOUTH_TAG: ${{ steps.filter.outputs.web == 'true' && needs.build.outputs.image_version || 'latest' }}
continue-on-error: true
- name: Start services
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
run: |-
docker compose -f ./src/api/docker-compose.yml up -d
docker compose -f ./src/web/docker-compose.yml up -d
Expand All @@ -276,22 +274,12 @@ jobs:
YOUTH_TAG: ${{ steps.filter.outputs.web == 'true' && needs.build.outputs.image_version || 'latest' }}

- uses: actions/setup-node@v4
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
with:
node-version: 18
cache: yarn
- uses: cypress-io/github-action@v6
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
- name: Upload Cypress Screenshots
uses: actions/upload-artifact@v4
if: always()
Expand All @@ -308,36 +296,16 @@ jobs:
if-no-files-found: ignore

- name: Keycloak Config logs
if: always() && (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: always() && steps.should-run.outputs.run == 'true'
run: docker logs keycloak-config
- name: Keycloak logs
if: always() && (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: always() && steps.should-run.outputs.run == 'true'
run: docker logs keycloak
- name: Yoma API logs
if: always() && (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: always() && steps.should-run.outputs.run == 'true'
run: docker logs yoma-api
- name: Yoma Web logs
if: always() && (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: always() && steps.should-run.outputs.run == 'true'
run: docker logs yoma-web

- run: docker compose down -v
Expand Down Expand Up @@ -386,46 +354,32 @@ jobs:
keycloak:
- './src/keycloak/**'
- './helm/keycloak/**'
- name: Should deploy?
id: should-run
run: |-
if [ "${{ steps.filter.outputs.api }}" = "true" ] || \
[ "${{ steps.filter.outputs.web }}" = "true" ] || \
[ "${{ steps.filter.outputs.keycloak }}" = "true" ] || \
[ "${{ github.event_name == 'workflow_dispatch' }}" = "true" ]; then
echo run=true >> $GITHUB_OUTPUT
else
echo run=false >> $GITHUB_OUTPUT
fi
- uses: unfor19/install-aws-cli-action@v1
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
- name: SOPS Binary Installer
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
uses: mdgreenwald/[email protected]
- uses: aws-actions/configure-aws-credentials@v4
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: github-cicd
- run: aws eks update-kubeconfig --name ${{ secrets.CLUSTER }}
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
- uses: tailscale/github-action@main
if: (
steps.filter.outputs.api == 'true' ||
steps.filter.outputs.web == 'true' ||
steps.filter.outputs.keycloak == 'true' ||
github.event_name == 'workflow_dispatch'
)
if: steps.should-run.outputs.run == 'true'
with:
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
version: ${{ env.TAILSCALE_VERSION }}
Expand Down

0 comments on commit 4a9aeff

Please sign in to comment.