Merge pull request #32 from Seelly/master #17
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: xzdp CI | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
fmt: | |
name: Run go fmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22 | |
- name: Run go fmt | |
run: | | |
fmt_output=$(go fmt ./...) | |
if [ -n "$fmt_output" ]; then | |
echo "The following files need to be formatted:" | |
echo "$fmt_output" | |
exit 1 | |
fi | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22 | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Build | |
run: ./script/build.sh | |
test: | |
name: Run tests | |
runs-on: ubuntu-latest | |
needs: build | |
services: | |
redis: | |
image: redis:latest | |
ports: | |
- 6379:6379 | |
mysql: | |
image: mysql:latest | |
env: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: xzdp | |
ports: | |
- 3306:3306 | |
options: >- | |
--health-cmd="mysqladmin ping --silent" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=3 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.22 | |
- name: Install dependencies | |
run: go mod tidy | |
- name: Wait for MySQL to be ready | |
run: | | |
until mysqladmin ping -h 127.0.0.1 --silent; do | |
echo "Waiting for MySQL..." | |
sleep 2 | |
done | |
- name: Import SQL file into MySQL | |
run: | | |
mysql -h 127.0.0.1 -P 3306 -u root -ppassword xzdp < resources/xzdp.sql | |
- name: Run tests | |
env: | |
REDIS_HOST: 127.0.0.1 | |
REDIS_PORT: 6379 | |
MYSQL_HOST: 127.0.0.1 | |
MYSQL_PORT: 3306 | |
MYSQL_USER: root | |
MYSQL_PASSWORD: password | |
MYSQL_DATABASE: xzdp | |
run: ./script/test.sh |