This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
chore(deps): bump actions/download-artifact from 3 to 4 #515
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: tests | |
on: | |
push: | |
branches: [master, main] | |
paths-ignore: ['**.md'] | |
tags-ignore: ['**'] | |
pull_request: | |
paths-ignore: ['**.md'] | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
gitleaks: | |
name: Gitleaks | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: {fetch-depth: 0} | |
- name: Check for GitLeaks | |
uses: gacts/gitleaks@v1 # Action page: <https://github.com/gacts/gitleaks> | |
golangci-lint: | |
name: Golang-CI (lint) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: gacts/setup-go-with-cache@v1 | |
with: {go-version: 1.19} | |
- uses: golangci/golangci-lint-action@v3 # Action page: <https://github.com/golangci/golangci-lint-action> | |
with: {skip-pkg-cache: true, skip-build-cache: true} | |
go-test: | |
name: Unit tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: {fetch-depth: 2} # Fixes codecov error 'Issue detecting commit SHA' | |
- uses: gacts/setup-go-with-cache@v1 | |
with: {go-version-file: go.mod} | |
- run: go test -race -covermode=atomic -coverprofile /tmp/coverage.txt ./... | |
- name: Upload Coverage report to CodeCov | |
continue-on-error: true | |
uses: codecov/codecov-action@v3 # https://github.com/codecov/codecov-action | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
file: /tmp/coverage.txt | |
build: | |
name: Build for ${{ matrix.os }} (${{ matrix.arch }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [linux, windows, darwin] # linux, freebsd, darwin, windows | |
arch: [amd64] # amd64, 386 | |
include: | |
- os: linux | |
arch: 386 | |
- os: windows | |
arch: 386 | |
needs: [golangci-lint, go-test] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: gacts/setup-go-with-cache@v1 | |
with: {go-version-file: go.mod} | |
- {uses: gacts/github-slug@v1, id: slug} | |
- env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
CGO_ENABLED: 0 | |
LDFLAGS: -s -w -X gh.tarampamp.am/mikrotik-hosts-parser/v4/internal/pkg/version.version=${{ steps.slug.outputs.branch-name-slug }}@${{ steps.slug.outputs.commit-hash-short }} | |
run: go build -trimpath -ldflags "$LDFLAGS" -o /tmp/mikrotik-hosts-parser ./cmd/mikrotik-hosts-parser/ | |
- name: Try to execute | |
if: matrix.os == 'linux' | |
run: /tmp/mikrotik-hosts-parser version && /tmp/mikrotik-hosts-parser -h | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: mikrotik-hosts-parser-${{ matrix.os }}-${{ matrix.arch }} | |
path: /tmp/mikrotik-hosts-parser | |
if-no-files-found: error | |
retention-days: 1 | |
e2e: | |
name: End-to-End tests (cache in ${{ matrix.caching-engine }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
caching-engine: [memory, redis] | |
needs: [build] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Start redis server | |
if: matrix.caching-engine == 'redis' | |
run: docker run --rm -d -p "6379:6379/tcp" redis:7-alpine | |
- name: Download compiled binary file | |
uses: actions/download-artifact@v4 | |
with: | |
name: mikrotik-hosts-parser-linux-amd64 | |
path: .artifact | |
- name: Prepare binary file to run | |
working-directory: .artifact | |
run: mv ./mikrotik-hosts-parser ./../app && chmod +x ./../app | |
- name: Start HTTP server | |
run: ./app serve --debug --port 8081 --caching-engine "${{ matrix.caching-engine }}" --redis-dsn "redis://127.0.0.1:6379/0" & | |
- name: Run Newman | |
uses: ./.github/actions/newman | |
with: | |
baseurl: 'http://127.0.0.1:8081' | |
docker-image: | |
name: Build docker image | |
runs-on: ubuntu-latest | |
needs: [golangci-lint, go-test] | |
steps: | |
- uses: actions/checkout@v4 | |
- {uses: gacts/github-slug@v1, id: slug} | |
- name: Build image | |
run: | | |
docker build \ | |
-t mikrotik-hosts-parser:local \ | |
--build-arg "APP_VERSION=${{ steps.slug.outputs.branch-name-slug }}@${{ steps.slug.outputs.commit-hash-short }}" \ | |
-f ./Dockerfile \ | |
. | |
- run: docker run --rm mikrotik-hosts-parser:local version | |
- uses: anchore/scan-action@v3 # action page: <https://github.com/anchore/scan-action> | |
with: | |
image: mikrotik-hosts-parser:local | |
fail-build: false | |
severity-cutoff: low # negligible, low, medium, high or critical | |
- name: Save docker image | |
run: docker save mikrotik-hosts-parser:local > ./docker-image.tar | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docker-image | |
path: ./docker-image.tar | |
retention-days: 1 | |
docker-image-e2e: | |
name: Docker image End-to-End tests (cache in ${{ matrix.caching-engine }}) | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
caching-engine: [memory, redis] | |
needs: [docker-image] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create docker network | |
run: docker network create "app-network" | |
- name: Start redis server | |
if: matrix.caching-engine == 'redis' | |
run: docker run --rm -d --network "app-network" -p "6379:6379/tcp" --name=redis redis:7-alpine | |
- name: Download builded docker image | |
uses: actions/download-artifact@v4 | |
with: | |
name: docker-image | |
path: .artifact | |
- name: Prepare image to run | |
working-directory: .artifact | |
run: docker load < docker-image.tar | |
- name: Run docker image with app | |
run: | | |
docker run --rm -d \ | |
--network "app-network" \ | |
-p "8081:8081/tcp" \ | |
-e "CACHING_ENGINE=${{ matrix.caching-engine }}" \ | |
-e "REDIS_DSN=redis://redis:6379/0" \ | |
-e "LISTEN_PORT=8081" \ | |
mikrotik-hosts-parser:local | |
- name: Run Newman | |
uses: ./.github/actions/newman | |
with: | |
baseurl: 'http://127.0.0.1:8081' |