ci: add ci #3
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 | |
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: Run tests | |
env: | |
REDIS_HOST: 127.0.0.1 | |
REDIS_PORT: 6379 | |
run: ./script/test.sh |