Skip to content

Commit

Permalink
chore(ci): Run test actions only when relevant code changed for websi…
Browse files Browse the repository at this point in the history
…te, backend (#1695)
  • Loading branch information
corneliusroemer authored Apr 29, 2024
1 parent 6e0039c commit 8a6535e
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 77 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/backend-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: backend-tests

on:
pull_request:
paths:
- "backend/**"
- ".github/workflows/backend-tests.yml"
push:
branches:
- master
workflow_dispatch:

concurrency:
group: ci-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}-backend-tests
cancel-in-progress: true

jobs:
Tests:
runs-on: codebuild-loculus-ci-${{ github.run_id }}-${{ github.run_attempt }}
timeout-minutes: 15
env:
CROSSREF_USERNAME: ${{ secrets.CROSSREF_USERNAME }}
CROSSREF_TEST_PASSWORD: ${{ secrets.CROSSREF_TEST_PASSWORD }}
CROSSREF_TEST_ENDPOINT: ${{ secrets.CROSSREF_TEST_ENDPOINT }}
CROSSREF_DOI_PREFIX: ${{ secrets.CROSSREF_DOI_PREFIX }}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN_READ_PUBLIC }}
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "adopt"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Execute Tests
uses: nick-fields/retry@v3
with:
command: cd ./backend && ./gradlew test
max_attempts: 3
timeout_minutes: 10
retry_wait_seconds: 1
- name: Check Format And Lint
run: ./gradlew ktlintCheck
working-directory: ./backend
37 changes: 2 additions & 35 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,17 @@ on:
push:
workflow_dispatch:

env:
DOCKER_IMAGE_NAME: ghcr.io/loculus-project/backend
CROSSREF_USERNAME: ${{ secrets.CROSSREF_USERNAME }}
CROSSREF_TEST_PASSWORD: ${{ secrets.CROSSREF_TEST_PASSWORD }}
CROSSREF_TEST_ENDPOINT: ${{ secrets.CROSSREF_TEST_ENDPOINT }}
CROSSREF_DOI_PREFIX: ${{ secrets.CROSSREF_DOI_PREFIX }}

concurrency:
group: ci-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}-backend
cancel-in-progress: true

jobs:
Tests:
runs-on: codebuild-loculus-ci-${{ github.run_id }}-${{ github.run_attempt }}
timeout-minutes: 15
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN_READ_PUBLIC }}
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "adopt"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Execute Tests
uses: nick-fields/retry@v3
with:
command: cd ./backend && ./gradlew test
max_attempts: 3
timeout_minutes: 10
retry_wait_seconds: 1
- name: Check Format And Lint
run: ./gradlew ktlintCheck
working-directory: ./backend

dockerImage:
name: Build Backend Docker Image # Don't change: Referenced by .github/workflows/update-argocd-metadata.yml
runs-on: ubuntu-latest
timeout-minutes: 15
env:
DOCKER_IMAGE_NAME: ghcr.io/loculus-project/backend
permissions:
packages: write
contents: read
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/website-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: website-tests

on:
# test
pull_request:
paths:
- "website/**"
- ".github/workflows/website-tests.yml"
push:
branches:
- master
workflow_dispatch:

concurrency:
group: ci-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}-website-tests
cancel-in-progress: true

jobs:
checks:
name: Check format and types
runs-on: codebuild-loculus-ci-${{ github.run_id }}-${{ github.run_attempt }}
timeout-minutes: 15
defaults:
run:
working-directory: ./website
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('website/**/package-lock.json') }}
- run: npm ci
- run: npm run check-format
- run: npm run check-types

unitTests:
name: Unit Tests
runs-on: codebuild-loculus-ci-${{ github.run_id }}-${{ github.run_attempt }}
timeout-minutes: 15
defaults:
run:
working-directory: ./website
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache .npm
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('website/**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test
42 changes: 0 additions & 42 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,48 +12,6 @@ concurrency:
cancel-in-progress: true

jobs:
checks:
name: Check format and types
runs-on: codebuild-loculus-ci-${{ github.run_id }}-${{ github.run_attempt }}
timeout-minutes: 15
defaults:
run:
working-directory: ./website
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('website/**/package-lock.json') }}
- run: npm ci
- run: npm run check-format
- run: npm run check-types

unitTests:
name: Unit Tests
runs-on: codebuild-loculus-ci-${{ github.run_id }}-${{ github.run_attempt }}
timeout-minutes: 15
defaults:
run:
working-directory: ./website
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Cache .npm
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('website/**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test

dockerImage:
name: Build Website Docker Image # Don't change: Referenced by .github/workflows/update-argocd-metadata.yml
runs-on: ubuntu-latest
Expand Down

0 comments on commit 8a6535e

Please sign in to comment.