Update go.yml #5
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: Go | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.22.2' | |
- name: Start MySQL Docker container | |
run: | | |
docker run -d --name meu_app_db \ | |
-p 3308:3306 \ | |
-e MYSQL_ROOT_PASSWORD=meu_app_password_root \ | |
-e MYSQL_USER=meu_app_user \ | |
-e MYSQL_PASSWORD=meu_app_password \ | |
mysql:latest | |
- name: Build | |
run: go build -v ./... | |
- name: Test | |
run: | | |
# Aguarde alguns segundos para garantir que o MySQL esteja pronto | |
sleep 10 | |
# Execute os testes conectando ao banco de dados MySQL | |
go test -v ./... | |
- name: Stop MySQL Docker container | |
run: docker stop meu_app_db |