Skip to content

Commit

Permalink
Add git-action for running maven test
Browse files Browse the repository at this point in the history
This solved #11.
  • Loading branch information
Kaiser-Yang committed Oct 18, 2024
1 parent fad2bca commit b2a681e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/mvn-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Maven Test
on:
pull_request:
branches: [ master, develop ]

jobs:
maven-test:
# Containers must run in Linux based operating systems
runs-on: ubuntu-latest
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
- name: Preparation
run: |
bash prepare_dev.sh postgres
env:
POSTGRES_HOST: postgres
POSTGRES_PORT: 5432
- name: Maven Test
run: |
mvn test
7 changes: 5 additions & 2 deletions prepare_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
sudo apt-get update
sudo apt-get install -y postgresql postgresql-client openjdk-17-jdk-headless maven git openssh-server

POSTGRES_HOST=${POSTGRES_HOST:-localhost}
POSTGRES_PORT=${POSTGRES_PORT:-5432}

# init the database
sudo su -c 'psql -c "DROP DATABASE IF EXISTS gcs_dev;"' postgres
sudo su -c 'psql -c "CREATE DATABASE gcs_dev;"' postgres
bash database/database_deploy.sh postgres gcs_dev localhost 5432 "$1"
bash database/database_deploy.sh postgres gcs_dev "$POSTGRES_HOST" "$POSTGRES_PORT" "$1"

# configure gitolite
sudo userdel -r git
Expand Down Expand Up @@ -41,7 +44,7 @@ echo "$USER ALL=(git) NOPASSWD: /usr/bin/rm" | sudo tee /etc/sudoers.d/gcs_dev
echo "
spring.datasource.druid.username=postgres
spring.datasource.druid.password=$1
spring.datasource.druid.url=jdbc:postgresql://localhost:5432/gcs_dev
spring.datasource.druid.url=jdbc:postgresql://$POSTGRES_HOST:$POSTGRES_PORT/gcs_dev
spring.datasource.druid.stat-view-servlet.login-username=druid
spring.datasource.druid.stat-view-servlet.login-password=druid
spring.profiles.active=dev
Expand Down

0 comments on commit b2a681e

Please sign in to comment.