feat: add benchmark functionality with Docker setup and update API ra… #23
This file contains hidden or 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: Tests and Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - v[0-9].[0-9].[0-9]+ | |
| - v[0-9].[0-9]+.[0-9]+-beta | |
| pull_request: | |
| branches: | |
| - main | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Run tests | |
| run: go test -v ./... | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Build application | |
| run: go build -v ./... | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Install dependencies | |
| run: go mod download | |
| - name: Build application | |
| run: make build && chmod +x ./wserver | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v2 | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - name: Seed DNE (Correios Data) | |
| run: | | |
| chmod +x ./scripts/dne_download.sh | |
| ./scripts/dne_download.sh ${{ secrets.DNE_USERNAME }} ${{ secrets.DNE_PASSWORD }} | |
| echo "Seeding DNE data..." | |
| MODE=seed ./wserver | |
| tar -czf data.tar.gz data/ | |
| rm -rf ./dne/ | |
| - name: Get version tag | |
| id: get_tag | |
| run: | | |
| if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then | |
| echo "tag=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT | |
| else | |
| echo "tag=${GITHUB_SHA:0:7}-unstable" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| brasilcep/api:latest | |
| brasilcep/api:${{ steps.get_tag.outputs.tag }} |