Bump actions/checkout from 4 to 5 #38
Workflow file for this run
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: Go | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
GO_VERSION: '1.24' | |
jobs: | |
test: | |
name: Test and Build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
project: [url-shortener, wc] | |
go-version: [1.24] | |
services: | |
redis: | |
image: redis:7-alpine | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- name: Set up Go ${{ matrix.go-version }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Cache Go modules | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ matrix.project }}-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-${{ matrix.go-version }}-${{ matrix.project }}- | |
- name: Verify dependencies | |
working-directory: ${{ matrix.project }} | |
run: go mod verify | |
- name: Run tests | |
working-directory: ${{ matrix.project }} | |
run: go test -v -race ./... | |
- name: Build | |
working-directory: ${{ matrix.project }} | |
run: go build -v ./... | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
project: [url-shortener, wc] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.24 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v8 | |
with: | |
version: latest | |
working-directory: ${{ matrix.project }} | |
args: --timeout=5m | |
docker-build: | |
name: Build Docker Image | |
runs-on: ubuntu-latest | |
needs: [test, lint] | |
strategy: | |
matrix: | |
project: [url-shortener] | |
env: | |
DOCKER_IMAGE_NAME: url-shortener | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v5 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Build Docker image | |
working-directory: ${{ matrix.project }} | |
run: docker build -t ${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} . | |
- name: Test Docker image | |
working-directory: ${{ matrix.project }} | |
run: | | |
docker run -d --name test-container -p 8000:8000 ${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }} | |
sleep 10 | |
curl -f http://localhost:8000/health || exit 1 | |
docker stop test-container | |
docker rm test-container |