├── .github └── workflows │ ├── README.md │ └── ci.yaml ├── Dockerfile ├── go.mod ├── math.go └── math_test.go /.github/workflows/README.md: -------------------------------------------------------------------------------- 1 | ***Projeto de exemplo de pipeline com o Git hub actions*** -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: ci-golang-workflow 2 | on: 3 | pull_request: 4 | branches: 5 | - develop 6 | jobs: 7 | check-application: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - uses: actions/setup-go@v2 12 | with: 13 | go-version: 1.15 14 | - run: go test 15 | - run: go run math.go 16 | - name: Set up QEMU 17 | uses: docker/setup-qemu-action@v1 18 | 19 | - name: Set up Docker Buildx 20 | uses: docker/setup-buildx-action@v1 21 | 22 | - name: Login to DockerHub 23 | uses: docker/login-action@v1 24 | with: 25 | username: ${{ secrets.DOCKERHUB_USERNAME }} 26 | password: ${{ secrets.DOCKERHUB_TOKEN }} 27 | 28 | - name: Build and push 29 | id: docker_build 30 | uses: docker/build-push-action@v2 31 | with: 32 | push: false 33 | tags: wesleywillians/fc2.0-ci-go:latest 34 | 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.19 2 | 3 | WORKDIR /app 4 | 5 | RUN go mod init teste 6 | 7 | COPY . . 8 | 9 | RUN go build -o math 10 | 11 | CMD ["./math"] -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module teste 2 | 3 | go 1.19 4 | -------------------------------------------------------------------------------- /math.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(soma(112, 10)) 7 | } 8 | 9 | func soma(a int, b int) int { 10 | return a + b 11 | } 12 | -------------------------------------------------------------------------------- /math_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func TestSoma(t *testing.T) { 6 | 7 | total := soma(15, 15) 8 | 9 | if total != 30 { 10 | t.Errorf("Resultado da some é inválido: Resultado %d. Esperado: %d", total, 30) 11 | } 12 | } 13 | --------------------------------------------------------------------------------