Skip to content

Commit

Permalink
chore: Migrate to go tools image usage (#81)
Browse files Browse the repository at this point in the history
* chore: Remove vendored tools

* refactor: Scripts and makefile to support go tools image

* chore: Add go tools docker compose

* chore: Bump go version to 1.20

* ci: Refactor ci

* ci: Add codeql

* ci: Fix release pipeline

* ci: Add sonar config
  • Loading branch information
obalunenko committed Mar 12, 2023
1 parent 09c4b94 commit e2ce613
Show file tree
Hide file tree
Showing 7,890 changed files with 742 additions and 2,011,024 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
58 changes: 58 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '31 10 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: true
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

- name: Build
run: |
make vet
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
195 changes: 192 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
name: Go [lint, test]

on:
workflow_dispatch:
push:
branches:
- 'master'
paths:
- 'scripts/**'
- 'tools/**'
- '**/*.go'
- '**/*.gohtml'
- '**/*.proto'
- 'go.mod'
- 'go.sum'
- 'Makefile'
- '!**.*md'
- '.github/workflows/**'
- '!.github/workflows/readme-stars.yml'
- 'deployments/docker-compose/go-tools-docker-compose.yml'
pull_request:
types: [ opened, synchronize, reopened ]
branches:
Expand All @@ -18,15 +32,111 @@ on:
- 'go.sum'
- 'Makefile'
- '!**.*md'
- '.github/workflows/**'
- '!.github/workflows/readme-stars.yml'

jobs:
build:
strategy:
fail-fast: false
max-parallel: 3
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Build
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up go
uses: actions/setup-go@v3.5.0
with:
go-version: ${{ matrix.go }}

- run: |
go version
shell: bash
- name: Set up cache
uses: actions/cache@v3
env:
cache-name: cache-vendored-tools-${{ secrets.CACHE_VERSION }}
with:
path: |
${{ env.GOBIN }}
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
install-only: true

- name: Check release
run: |
make check-releaser
shell: bash

testing:
strategy:
fail-fast: false
max-parallel: 2
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Run Tests
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up go
uses: actions/setup-go@v3.5.0
with:
go-version: ${{ matrix.go }}

- run: |
go version
shell: bash
- name: Set up cache
uses: actions/cache@v3
env:
cache-name: cache-vendored-tools-${{ secrets.CACHE_VERSION }}
with:
path: |
${{ env.GOBIN }}
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
- name: Install tools
run: |
make install-tools
shell: bash

- name: Test
run: |
make test
shell: bash

linting:
strategy:
fail-fast: false
max-parallel: 2
matrix:
os: [ 'ubuntu-20.04' ]
go: [ '1.18' ]
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Run linters
steps:
Expand All @@ -38,21 +148,100 @@ jobs:
- name: Set up go
uses: actions/setup-go@v3.5.0
with:
stable: 'true'
go-version: ${{ matrix.go }}
- run: |
go version
shell: bash
- name: Vet
run: |
make vet
shell: bash

- name: Set up cache
uses: actions/cache@v3
env:
cache-name: cache-vendored-tools-${{ secrets.CACHE_VERSION }}
with:
path: |
${{ env.GOBIN }}
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
- name: Install tools
run: |
make install-tools
shell: bash

- name: Lint
run: |
make lint-pipeline
shell: bash

reports:
needs: [ testing, linting, build ]
strategy:
fail-fast: true
max-parallel: 1
matrix:
os: [ 'ubuntu-22.04' ]
go: [ '1.20' ]
runs-on: ${{ matrix.os }}
name: Quality reports
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up go
uses: actions/setup-go@v3.5.0
with:
go-version: ${{ matrix.go }}
- run: |
go version
shell: bash
- name: Set up cache
uses: actions/cache@v3
env:
cache-name: cache-vendored-tools-${{ secrets.CACHE_VERSION }}
with:
path: |
${{ env.GOBIN }}
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/tools/go.sum') }}
- name: Install tools
run: |
make install-tools
shell: bash

- name: Prepare test coverage and reports
run: |
make prepare-cover-report
shell: bash

- name: Prepare lint report
run: |
make lint-sonar
shell: bash

- name: Cover report upload
if: success()
run: |
bash <(curl -s https://codecov.io/bash) -f ./coverage/full.cov
shell: bash

- name: SonarCloud report upload
uses: sonarsource/sonarcloud-github-action@v1.9
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 comments on commit e2ce613

Please sign in to comment.