Skip to content

Feature/build all

Feature/build all #19

Workflow file for this run

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: Go
on:
push:
branches: [ "*", "**" ]
pull_request:
branches: [ "*", "**" ]
env:
IMAGE_NAME: fakes3pp
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Golangci-lint
uses: golangci/[email protected]
with:
# The version of golangci-lint to use.
version: v1.61.0
# The mode to install golangci-lint. It can be 'binary' or 'goinstall'.
install-mode: binary
# golangci-lint working directory, default is project root
#working-directory: # optional
# the token is used for fetching patch of a pull request to show only new issues
#github-token: # optional, default is ${{ github.token }}
# if set to true and the action runs on a pull request - the action outputs only newly found issues
#only-new-issues: # optional, default is false
# if set to true then the all caching functionality will be complete disabled, takes precedence over all other caching options.
#skip-cache: # optional, default is false
# if set to true then the action will not save any caches, but it may still restore existing caches, subject to other options.
#skip-save-cache: # optional, default is false
# Force the usage of the embedded problem matchers
#problem-matchers: # optional, default is false
# golangci-lint command line arguments
#args: # optional, default is
# Periodically invalidate a cache because a new code being added. (number of days)
#cache-invalidation-interval: # optional, default is 7
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build
run: go build -v ./...
- name: Setup test dependencies
run: |
make setup-test-dependencies
make start-test-s3-servers
- name: Test
# As we use config files from time to time we always want to run without cache
run: go clean -testcache && go test -coverprofile cover.out -v ./...
- name: Vet
run: go vet
# This pushes the image to GitHub Packages.
push:
runs-on: ubuntu-latest
needs: [build]
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup test dependencies
run: |
make setup-test-dependencies
make start-test-s3-servers
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
#
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
# This changes all uppercase characters to lowercase.
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# This strips the git ref prefix from the version.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# This strips the "v" prefix from the tag name.
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# This uses the Docker `latest` tag convention.
[ "$VERSION" == "main" ] && VERSION=latest
# Use commit hash if no other applicable tag
[ "$VERSION" != "latest" ] && [[ "${{ github.ref }}" != "refs/tags/"* ]] && VERSION="commit-$GITHUB_SHA"
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION