Build+Test(+Push) run 1508 from push (main) #1508
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(+Push) | |
run-name: ${{ github.workflow }} run ${{github.run_number}} from ${{github.event_name}} (${{github.head_ref || github.ref_name}}) | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-(${{github.ref}}-${{github.event_name}} | |
cancel-in-progress: true | |
jobs: | |
code_check: | |
runs-on: "ubuntu-22.04" | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: v20.11.0 | |
cache: npm | |
- name: Code check | |
uses: ./.github/actions/code_check | |
localization_check_untuva: | |
runs-on: "ubuntu-22.04" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Localization check | |
uses: ./.github/actions/localization_check | |
with: | |
ludos-environment: untuva | |
localization_check_qa: | |
runs-on: "ubuntu-22.04" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Localization check | |
uses: ./.github/actions/localization_check | |
with: | |
ludos-environment: qa | |
localization_check_prod: | |
runs-on: "ubuntu-22.04" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Localization check | |
uses: ./.github/actions/localization_check | |
with: | |
ludos-environment: prod | |
vitest: | |
runs-on: "ubuntu-22.04" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Vitest | |
uses: ./.github/actions/vitest | |
build-jar-and-test-api: | |
runs-on: "ubuntu-22.04" | |
permissions: | |
id-token: write | |
contents: read | |
checks: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: v20.11.0 | |
cache: npm | |
- name: npm install | |
run: npm ci | |
- name: Set up Java 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: zulu | |
- name: Start database for API tests | |
run: docker compose up -d | |
- name: Configure untuva AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 # More information on this action can be found below in the 'AWS Credentials' section | |
with: | |
role-to-assume: arn:aws:iam::782034763554:role/ludos-github-actions-role-untuva | |
aws-region: eu-west-1 | |
- name: Gradle build, including API tests | |
uses: gradle/actions/setup-gradle@v3 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
arguments: build | |
build-root-directory: server | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() # run this step even if previous step failed | |
with: | |
name: gradle-test-report | |
path: server/build/test-results/test/TEST-*.xml | |
reporter: java-junit | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: build-debug-artifacts | |
path: | | |
server/build/reports/ | |
retention-days: 7 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: jar | |
path: server/build/libs/ludos.jar | |
retention-days: 30 | |
if-no-files-found: error | |
playwright-parallel: | |
runs-on: "ubuntu-22.04" | |
needs: [ "build-jar-and-test-api" ] | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Playwright | |
uses: ./.github/actions/playwright | |
with: | |
npm-script: 'test:parallel_tests' | |
ludos-profiles: local | |
testikayttaja-yllapitaja-username: ${{ secrets.TESTIKAYTTAJA_YLLAPITAJA_USERNAME }} | |
testikayttaja-yllapitaja-password: ${{ secrets.TESTIKAYTTAJA_YLLAPITAJA_PASSWORD }} | |
ludos-palvelukayttaja-username: ${{ secrets.LUDOS_PALVELUKAYTTAJA_USERNAME }} | |
ludos-palvelukayttaja-password: ${{ secrets.LUDOS_PALVELUKAYTTAJA_PASSWORD }} | |
playwright-non-parallel: | |
runs-on: "ubuntu-22.04" | |
needs: [ "build-jar-and-test-api" ] | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Playwright | |
uses: ./.github/actions/playwright | |
with: | |
npm-script: 'test:non_parallel_tests' | |
ludos-profiles: local | |
testikayttaja-yllapitaja-username: ${{ secrets.TESTIKAYTTAJA_YLLAPITAJA_USERNAME }} | |
testikayttaja-yllapitaja-password: ${{ secrets.TESTIKAYTTAJA_YLLAPITAJA_PASSWORD }} | |
ludos-palvelukayttaja-username: ${{ secrets.LUDOS_PALVELUKAYTTAJA_USERNAME }} | |
ludos-palvelukayttaja-password: ${{ secrets.LUDOS_PALVELUKAYTTAJA_PASSWORD }} | |
build-docker-image-and-push: | |
runs-on: "ubuntu-22.04" | |
needs: [ "build-jar-and-test-api", "playwright-parallel", "playwright-non-parallel" ] | |
if: github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch' || github.run_attempt >= 2 | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v4 | |
- name: calculate short sha | |
id: short-sha | |
run: echo "short-sha=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT | |
- name: get branch name | |
id: branch-name | |
run: echo "branch-name=${{ github.event.pull_request && github.head_ref || github.ref_name }}" >> $GITHUB_OUTPUT | |
- uses: actions/download-artifact@v4 | |
with: | |
name: jar | |
path: server/build/libs | |
- name: Configure utility AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 # More information on this action can be found below in the 'AWS Credentials' section | |
with: | |
role-to-assume: arn:aws:iam::505953557276:role/ludos-gh-actions-ecr-push-role | |
aws-region: eu-west-1 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
with: | |
mask-password: 'true' | |
- name: Calculate image tag | |
id: image-tag | |
env: | |
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
REPOSITORY: ludos | |
IMAGE_TAG: ludos-${{ github.run_number }}-${{ steps.branch-name.outputs.branch-name }}-${{ steps.short-sha.outputs.short-sha }} | |
run: | | |
echo "image-tag=${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT | |
echo "image-tag-with-registry=${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}" >> $GITHUB_OUTPUT | |
echo "::notice title=Image tag::${{ env.IMAGE_TAG }}" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
file: docker-build/Dockerfile | |
context: . | |
tags: ${{ steps.image-tag.outputs.image-tag-with-registry }} | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |