ms2/share modal improvements #2029
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
name: Build, test, and deploy | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment to deploy to' | |
type: environment | |
required: true | |
env: | |
OUTPUT_PATH_ENGINE_NODE: './build/engine/' | |
OUTPUT_PATH_ENGINE_ANDROID: './src/engine/native/android/app/build/outputs/apk/debug/' | |
OUTPUT_PATH_MS_SERVER: './src/management-system-v2/.next/' | |
DOCKER_PATH_MS_SERVER: './src/management-system-v2' | |
FILE_NAME_NODE_ENGINE: 'PROCEED-Engine-0.1.0.zip' | |
FILE_NAME_ANDROID: 'PROCEED-Engine-0.1.0.apk' | |
jobs: | |
install: | |
runs-on: ubuntu-latest | |
# outputs: | |
# compose: ${{ steps.changes.outputs.compose }} | |
steps: | |
- uses: actions/checkout@v4 | |
# - uses: dorny/paths-filter@v3 | |
# id: changes | |
# with: | |
# filters: | | |
# compose: | |
# - 'docker-compose.yml' | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- run: yarn install --frozen-lockfile --ignore-engines # Remove once node-ipc is removed | |
# Cache for this workflow run. | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: cache-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
lint: | |
runs-on: ubuntu-latest | |
needs: install | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- run: yarn prettier --check . | |
testEngine: | |
runs-on: ubuntu-latest | |
needs: install | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- run: yarn test-engine --ci | |
testEngineE2E: | |
runs-on: ubuntu-latest | |
needs: install | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- run: yarn test-e2e --ci | |
testMS: | |
runs-on: ubuntu-latest | |
needs: install | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- run: yarn test-ms --ci | |
buildEngine: | |
runs-on: ubuntu-latest | |
if: ${{ github.ref == 'refs/heads/main' }} | |
needs: | |
- lint | |
- testEngine | |
- testEngineE2E | |
- testMS | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- run: yarn build | |
- name: Upload engine build | |
uses: actions/upload-artifact@v4 | |
with: | |
name: PROCEED_Engine | |
path: ${{ env.OUTPUT_PATH_ENGINE_NODE }} | |
# buildEngineAndroid: | |
# runs-on: ubuntu-latest | |
# if: ${{ github.ref == 'refs/heads/main' }} | |
# needs: | |
# - lint | |
# - testEngine | |
# - testEngineE2E | |
# steps: | |
# - uses: actions/cache@v4 | |
# timeout-minutes: 2 | |
# id: restore-install | |
# with: | |
# path: ./* | |
# key: ${{ github.sha }}-${{ github.run_number }} | |
# | |
# - name: Set up Node.js | |
# uses: actions/setup-node@v4 | |
# with: | |
# node-version: 20 | |
# check-latest: true | |
# cache: 'yarn' | |
# | |
# - run: yarn build-android | |
# - run: cp ${{ env.OUTPUT_PATH_ENGINE_ANDROID }}/app-debug.apk ${{ env.BUILD_PATH_ENGINE_ANDROID }}/${{ env.FILE_NAME_ANDROID }} | |
# | |
# - name: Upload android engine build | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: PROCEED_Engine_Android | |
# path: ${{ env.OUTPUT_PATH_ENGINE_ANDROID }}/${{ env.FILE_NAME_ANDROID }} | |
buildMS: | |
runs-on: ubuntu-latest | |
env: | |
IMAGE_TAG: ${{ inputs.environment == 'Production' && 'latest' || 'edge' }} | |
outputs: | |
tag: ${{ steps.set_tag.outputs.tag }} | |
needs: | |
- lint | |
- testEngine | |
- testEngineE2E | |
- testMS | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- run: yarn build-ms | |
# Get the tag for the image, either var for staging/production or branch | |
# name for PRs. Taken from https://github.com/aevea/action-kaniko/blob/master/entrypoint.sh | |
- id: set_tag | |
run: | | |
TAG=$(git describe --tags --always --dirty --abbrev=7) | |
if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then | |
echo "tag=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT | |
else | |
echo "tag=$TAG" >> $GITHUB_OUTPUT | |
fi | |
- name: Kaniko build | |
uses: aevea/action-kaniko@master | |
with: | |
image: proceed/ms-server | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
path: ${{ env.DOCKER_PATH_MS_SERVER }} | |
tag: ${{ steps.set_tag.outputs.tag }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: buildMS | |
permissions: | |
contents: read | |
id-token: write | |
pull-requests: write | |
issues: write | |
#strategy: | |
# matrix: | |
# # Run a job each for the engine and MS server images | |
# include: | |
# - serviceName: engine | |
# - serviceName: management_system | |
env: | |
MS_TAG: ${{ needs.buildMS.outputs.tag }} | |
SERVICE_NAME: ${{ inputs.environment == 'Production' && 'ms-server-production' || 'ms-server-staging' }} | |
SUBDOMAIN: ${{ inputs.environment == 'Production' && 'app' || 'staging' }} | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: 'proceed-bpms' | |
workload_identity_provider: 'projects/1062024918148/locations/global/workloadIdentityPools/github-ci/providers/github' | |
service_account: '[email protected]' | |
- id: 'deploy' | |
if: ${{ github.ref == 'refs/heads/main' }} | |
uses: 'google-github-actions/deploy-cloudrun@v2' | |
with: | |
service: ${{ env.SERVICE_NAME }} | |
image: 'docker.io/proceed/ms-server:${{ env.MS_TAG }}' | |
env_vars: | | |
NEXTAUTH_URL=https://${{ env.SUBDOMAIN }}.proceed-labs.org | |
region: 'europe-west1' | |
revision_traffic: LATEST=100 | |
# The traffic update has to be its own step, as it needs to run after | |
# the deployment. | |
#- id: 'update-traffic' | |
# if: ${{ github.ref == 'refs/heads/main' }} | |
# uses: 'google-github-actions/deploy-cloudrun@v2' | |
# with: | |
# service: ${{ env.SERVICE_NAME }} | |
# region: 'europe-west1' | |
# revision_traffic: LATEST=100 | |
- id: 'deploy-preview' | |
if: ${{ github.event_name == 'pull_request' }} | |
name: Preview Cloud Run Deployment | |
uses: OhKai/preview-cloudrun@main | |
with: | |
service: ${{ env.SERVICE_NAME }} | |
image: docker.io/proceed/ms-server:${{ env.MS_TAG }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
region: 'europe-west1' | |
# Extra job to show environments in GitHub without failing deploy on PRs. | |
githubEnvironment: | |
runs-on: ubuntu-latest | |
needs: deploy | |
if: ${{ github.ref == 'refs/heads/main' }} | |
environment: | |
name: ${{ inputs.environment || 'Staging' }} | |
url: ${{ inputs.environment == 'Production' && 'https://app.proceed-labs.org' || 'https://staging.proceed-labs.org' }} | |
# NOOP job to show environment in GitHub | |
steps: | |
- run: echo "${{ inputs.environment || 'Staging' }}" | |
testE2E: | |
needs: deploy | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
if: ${{ inputs.environment != 'Production' }} | |
strategy: | |
matrix: | |
shard: [1, 2, 3, 4] | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
# TODO: cache these? | |
- name: Install Playwright Browsers | |
run: yarn playwright install --with-deps | |
- name: Run Playwright tests | |
run: yarn playwright test --shard=${{ matrix.shard }}/${{ strategy.job-total }} | |
env: | |
PLAYWRIGHT_TEST_BASE_URL: ${{ github.event_name == 'pull_request' && format('https://pr-{0}---ms-server-staging-c4f6qdpj7q-ew.a.run.app', github.event.number) || 'https://staging.proceed-labs.org' }} | |
- uses: actions/upload-artifact@v4 | |
if: ${{ !cancelled() }} | |
with: | |
name: all-blob-reports-${{ matrix.shard }} | |
path: blob-report | |
retention-days: 1 | |
create-report: | |
name: 📔 Create test report | |
if: always() | |
needs: [testE2E] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/cache@v4 | |
timeout-minutes: 2 | |
id: restore-install | |
with: | |
path: ./* | |
key: ${{ github.sha }}-${{ github.run_number }} | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
check-latest: true | |
cache: 'yarn' | |
- name: Download blob reports from GitHub Actions Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: all-blob-reports-* | |
merge-multiple: true | |
path: all-blob-reports | |
- name: Merge into HTML Report | |
run: npx playwright merge-reports --reporter html ./all-blob-reports | |
- name: Upload HTML report | |
uses: actions/upload-artifact@v4 | |
with: | |
name: html-report--attempt-${{ github.run_attempt }} | |
path: playwright-report | |
retention-days: 7 |