tests: fixing tests on redis server #6
Workflow file for this run
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: CI/CD | |
on: | |
pull_request: | |
types: [opened, edited, synchronize, reopened, ready_for_review] | |
branches: | |
- "*" | |
push: | |
branches: | |
- main | |
env: | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_PAT: ${{ secrets.DOCKER_HUB_PAT }} | |
DOCKER_CONTAINER: gcstatus-api | |
DOCKER_PORT: ${{ secrets.DOCKER_PORT }} | |
jobs: | |
tests: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
go: [1.22.0] | |
name: Running tests - GoLang v${{ matrix.go }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup GoLang | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go }} | |
- name: Cache go.sum | |
uses: actions/cache@v4 | |
id: sum-cache | |
with: | |
key: ${{ runner.os }}-sum-${{ hashFiles('go.sum') }} | |
path: vendor | |
- name: Install go dependencies | |
if: steps.sum-cache.outputs.cache-hit != 'true' | |
run: | | |
go mod download | |
go mod vendor | |
- name: Execute tests | |
run: go test ./tests/... | |
all_required_checks_passed: | |
name: All required checks passed | |
runs-on: ubuntu-latest | |
needs: [tests] | |
if: contains(github.ref, 'refs/heads/main') != true | |
steps: | |
- name: Mark PR as ready to merge | |
run: exit 0 | |
release: | |
name: Generate a new release | |
needs: [tests] | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: true | |
matrix: | |
node: [22] | |
if: contains(github.ref, 'refs/heads/main') | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.release.outputs.version }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
- name: semantic release | |
id: release | |
run: | | |
npm i -D @semantic-release/exec | |
npx semantic-release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
runs-on: ubuntu-latest | |
needs: [release] | |
outputs: | |
version: ${{ needs.release.outputs.version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKER_HUB_USERNAME }} | |
password: ${{ env.DOCKER_HUB_PAT }} | |
- name: Create docker metadata | |
uses: docker/metadata-action@v3 | |
id: meta | |
with: | |
images: ${{ env.DOCKER_HUB_USERNAME }}/${{ env.DOCKER_CONTAINER }} | |
tags: | | |
type=semver,prefix=v,pattern={{version}},value=${{ needs.release.outputs.version }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
file: Dockerfile | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/amd64 | |
deploy-prod: | |
name: Deploy to Production | |
needs: [build] | |
uses: ./.github/workflows/deploy-production.yml | |
with: | |
container-tag: v${{ needs.build.outputs.version }} | |
secrets: inherit |