Skip to content

Build & Test

Build & Test #345

Workflow file for this run

name: Build & Test
on:
pull_request:
types:
- opened
- reopened
- synchronize
push:
branches:
- main
jobs:
unit-test:
name: Unit Test -- Java ${{ matrix.java }}
runs-on: ubuntu-latest
strategy:
matrix:
java: [11, 17]
steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
- name: Run Unit Tests With Maven
run: mvn -B test package
- name: Cache Built Code
if: ${{ matrix.java == 11}}
uses: actions/cache@v3.3.1
with:
key: built-code-${{ github.run_id }}
path: ./**/target
- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-reports-jdk${{ matrix.java }}
path: ./**/target/surefire-reports
- name: Save Artifacts
uses: actions/upload-artifact@v2
with:
name: liquibase-cassandra
path: |
target/*.jar
integration-tests:
name: Integration Tests -- Java ${{ matrix.java }} on Cassandra ${{ matrix.cassandra }}
runs-on: ubuntu-latest
needs: unit-test
strategy:
matrix:
java: [11, 17]
services:
cassandra-3:
image: liquibase/liquibase:cassandra-test-3
ports:
- "9042:9042"
cassandra-4:
image: liquibase/liquibase:cassandra-test-4
ports:
- "9043:9042"
steps:
- uses: actions/checkout@v2
- name: Restore Built Code
uses: actions/cache@v2
with:
key: built-code-${{ github.run_id }}
path: ./**/target
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
- name: Start Cassandra Container
run: docker run -p 9042:9042 -v $(pwd):/app --name mycassandra -e CASSANDRA_PASSWORD=Password1 -e CASSANDRA_PASSWORD_SEEDER=yes -d bitnami/cassandra
- name: Wait for cassandra to start up
run: sleep 90s
- name: Check cassandra status
run: docker ps -a
- name: Check cassandra logs
run: docker logs mycassandra
- name: Load Cassandra Config
run: docker exec mycassandra cqlsh -u cassandra -p Password1 localhost 9042 -f /app/test.cql
- name: Run Tests
run: mvn -B clean test verify
- name: Archive Test Results
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: test-reports-integration-jdk${{ matrix.java }}-cassandra${{ matrix.cassandra }}
path: ./**/target/surefire-reports
dependabot:
name: Merge dependabot
runs-on: ubuntu-latest
needs: unit-test
permissions:
contents: write
pull-requests: write
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1.3.1
- name: Approve patch and minor updates
if: ${{steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || steps.dependabot-metadata.outputs.update-type == 'version-update:semver-minor'}}
run: |
gh pr merge --auto --merge "$PR_URL"
gh pr review $PR_URL --approve -b "I'm **approving** this pull request because **it includes a patch or minor update**"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}