Skip to content

Commit

Permalink
Merge pull request #8 from raffis/next
Browse files Browse the repository at this point in the history
Improve build
  • Loading branch information
raffis authored Nov 21, 2022
2 parents 194bde0 + 5c09c69 commit 8333d7c
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 70 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
36 changes: 0 additions & 36 deletions .github/workflows/nightly.yaml

This file was deleted.

23 changes: 12 additions & 11 deletions .github/workflows/e2e.yaml → .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
name: e2e
name: pr-build

on:
pull_request:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f #v3.3.1
with:
go-version: 1.18.x
go-version: 1.19.x
- name: Restore Go cache
uses: actions/cache@v1
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 #v3.0.11
with:
path: /home/runner/work/_temp/_github_home/go/pkg/mod
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: fmt
run: make fmt
- name: vet
run: make vet
- name: Linting
run: make lint
- name: Run tests
- name: Tests
run: make test
- name: Send go coverage report
uses: shogo82148/actions-goveralls@v1
uses: shogo82148/actions-goveralls@31ee804b8576ae49f6dc3caa22591bc5080e7920 #v1.6.0
with:
path-to-profile: coverage.out
- name: Check if working tree is dirty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: size-label
name: pr-label
on: pull_request
jobs:
size-label:
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.head.repo.fork }}
steps:
- name: size-label
uses: "pascalgn/size-label-action@851c37f157f7d64e56f41ff5d2d80316299b2d47"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rebase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout the latest code
uses: actions/checkout@v2
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
with:
fetch-depth: 0
- name: Automatic Rebase
uses: cirrus-actions/rebase@1.3.1
uses: cirrus-actions/rebase@6e572f08c244e2f04f9beb85a943eb618218714d #1.7
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
27 changes: 16 additions & 11 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'image tag prefix'
required: true

permissions:
contents: write # needed to write releases
Expand All @@ -20,19 +15,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
with:
go-version: '1.18'
fetch-depth: 0
- uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f #v3.3.1
with:
go-version: '1.19'
- name: Restore Go cache
uses: actions/cache@9b0c1fce7a93df8e3bb8926b0d6e9d89e92f20a7 #v3.0.11
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Docker Login
uses: docker/#-action@v2
uses: docker/#-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a #v2.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Cosign
uses: sigstore/cosign-installer@main
- uses: anchore/sbom-action/download-syft@v0
uses: sigstore/cosign-installer@9becc617647dfa20ae7b1151972e9b3a2c338a2b #v2.8.1
- uses: anchore/sbom-action/download-syft@06e109483e6aa305a2b2395eabae554e51530e1d #v0.13.1
- name: Create release and SBOM
if: startsWith(github.ref, 'refs/tags/v')
uses: goreleaser/goreleaser-action@v2
Expand All @@ -41,3 +45,4 @@ jobs:
args: release --rm-dist --skip-validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
12 changes: 6 additions & 6 deletions .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
name: FOSSA
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
- name: Run FOSSA scan and upload build data
uses: fossa-contrib/fossa-action@v1
uses: fossa-contrib/fossa-action@6cffaa064112e1cf9b5798c6224f9487dc1ec316 #v1.2.0
with:
# FOSSA Push-Only API Token
fossa-api-key: 956b9b92c5b16eeca1467cebe104f2c3
Expand All @@ -30,12 +30,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 #v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 #codeql-bundle-20221020
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 #codeql-bundle-20221020
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@c3b6fce4ee2ca25bc1066aa3bf73962fda0e8898 #codeql-bundle-20221020
4 changes: 4 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ source:
enabled: true
name_template: "{{ .ProjectName }}_{{ .Version }}_source_code"

changelog:
use: github-native

sboms:
- id: source
artifacts: source
Expand Down Expand Up @@ -69,6 +72,7 @@ brews:
tap:
owner: raffis
name: gitops-zombies
token: "{{ .Env.REPO_TOKEN }}"
description: Identify kubernetes resources which are not managed by GitOps
homepage: https://github.com/raffis/{{ .ProjectName }}
folder: Formula
Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,15 @@ build:
install:
CGO_ENABLED=0 go install ./cmd

# go-install-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
# go-install-tool will 'go install' any package $2 and install it to $1
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
env -i bash -c "GOBIN=$(GOBIN) PATH=$(PATH) GOPATH=$(shell go env GOPATH) GOCACHE=$(shell go env GOCACHE) go install $(2)" ;\
rm -rf $$TMP_DIR ;\
}
endef

0 comments on commit 8333d7c

Please # to comment.