Skip to content

fix and add tests #1439

fix and add tests

fix and add tests #1439

Workflow file for this run

name: CI
on:
- push
- workflow_dispatch
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11.0.18
cache: 'gradle'
- name: Verify tests
run: |
sh scripts/verify-test-files.sh
- name: Ktfmt
run: ./gradlew ktfmtCheck
- name: Detekt - main
run: ./gradlew detektMain
- name: Detekt - tests
run: ./gradlew detektTest
unit-test:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11.0.18
cache: 'gradle'
- name: Build & Unit Test
run: |
xvfb-run --auto-servernum ./gradlew koverReport
zip -rg unit-test-results.zip build/reports/tests/unitTest
zip -rq coverage-html.zip build/reports/kover/html
- name: Export test results
uses: actions/upload-artifact@v4
with:
name: unit-test-results
path: unit-test-results.zip
- name: Export coverage stats
uses: actions/upload-artifact@v4
with:
name: kover-report
path: coverage-html.zip
- name: Export snapshots
uses: actions/upload-artifact@v4
if: failure()
with:
name: failed-snapshots
path: |
/home/runner/**/*.failed.png
/home/runner/**/*.comparison.png
- name: Update coverage
id: update-coverage
if: github.ref == 'refs/heads/main'
run: |
python scripts/update-coverage.py
- name: Commit coverage stats
uses: EndBug/add-and-commit@v9
if: github.ref == 'refs/heads/main'
with:
add: './README.md'
message: "Update coverage stats: ${{ steps.update-coverage.outputs.COVERAGE }}"
integration-and-e2e:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11.0.18
cache: 'gradle'
- name: Integration & E2E
env:
AWS_SYNC: ${{ secrets.AWS_SYNC }}
AWS_LOGS: ${{ secrets.AWS_LOGS }}
run: xvfb-run --auto-servernum ./gradlew integrationAndE2E --info
- name: Export test results
uses: actions/upload-artifact@v4
with:
name: integration-and-e2e-results
path: /home/runner/work/Dartzee/Dartzee/build/reports/tests/integrationAndE2E/**/*.html
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11.0.18
- name: Build JAR
run: ./gradlew jar --info
- name: Export JAR
uses: actions/upload-artifact@v4
with:
name: dartzee-jar
path: /home/runner/work/Dartzee/Dartzee/build/libs/Dartzee.jar
test-jar:
name: Test JAR - Java ${{ matrix.java-version }}
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [ build ]
strategy:
matrix:
java-version: [ 8, 11 ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: ${{ matrix.java-version }}
- name: Download JAR
uses: actions/download-artifact@v4
with:
name: dartzee-jar
path: /home/runner/work/Dartzee/Dartzee/build/libs
- name: Test JAR
run: |
nohup java -jar build/libs/Dartzee.jar > dartzee-log.log 2>&1 &
echo "Waiting for Dartzee to start..."
attempt_counter=0
max_attempts=10
until $(cat dartzee-log.log | grep -Eq [databaseCurrent]); do
if [ ${attempt_counter} -eq ${max_attempts} ];then
echo "Max attempts reached"
exit 1
fi
printf '.'
attempt_counter=$(($attempt_counter+1))
sleep 5
done
echo "Dartzee started successfully"