Skip to content

Commit

Permalink
Merge pull request #1 from chainguard-dev/add_ci_scripts
Browse files Browse the repository at this point in the history
chore: add CI scripts
  • Loading branch information
cpanato authored Dec 18, 2023
2 parents a36d393 + 534b803 commit 0342e9e
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .chainguard/source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2023 Chainguard, Inc
# SPDX-License-Identifier: Apache-2.0

spec:
authorities:
- keyless:
url: https://fulcio.sigstore.dev
identities:
- subjectRegExp: [email protected]$
issuer: https://accounts.google.com
ctlog:
url: https://rekor.sigstore.dev
- key:
# Allow commits signed by Github (merge commits)
kms: https://github.com/web-flow.gpg
33 changes: 33 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2023 Chainguard, Inc.
# SPDX-License-Identifier: Apache-2.0

name: ci

on:
push:
branches:
- main
pull_request:


jobs:
ci:
runs-on: ubuntu-latest

strategy:
matrix:
go_version:
- '1.19'
- '1.20'
- '1.21'

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: ${{ matrix.go_version }}
check-latest: true

- run: |
make test
26 changes: 26 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2023 Chainguard, Inc.
# SPDX-License-Identifier: Apache-2.0

name: lint

on:
push:
branches:
- 'main'
pull_request:

jobs:
golangci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: '1.21'
check-latest: true

- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.55
args: --timeout=5m --verbose
18 changes: 18 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright 2023 Chainguard, Inc.
# SPDX-License-Identifier: Apache-2.0

linters:
enable:
- errcheck
- gofmt
- goimports
- gosec
- gocritic
- misspell
- revive
- unused
output:
uniq-by-line: false
run:
issues-exit-code: 1
timeout: 10m
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
SHELL=/bin/bash -o pipefail

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif


GO ?= go
TEST_FLAGS ?= -v -cover

.PHONY: test
test:
$(GO) vet ./...
$(GO) test ${TEST_FLAGS} ./...
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ func updatePackage(modFile *modfile.File, name, version, modroot string) error {
// Check if the package is replaced first
for _, replace := range modFile.Replace {
if replace.Old.Path == name {
cmd := exec.Command("go", "mod", "edit", "-replace", fmt.Sprintf("%s=%s@%s", replace.Old.Path, name, version))
cmd := exec.Command("go", "mod", "edit", "-replace", fmt.Sprintf("%s=%s@%s", replace.Old.Path, name, version)) //nolint:gosec
cmd.Dir = modroot
return cmd.Run()
}
}

// No replace, just update!
cmd := exec.Command("go", "get", fmt.Sprintf("%s@%s", name, version))
cmd := exec.Command("go", "get", fmt.Sprintf("%s@%s", name, version)) //nolint:gosec
cmd.Dir = modroot
if err := cmd.Run(); err != nil {
return err
Expand Down

0 comments on commit 0342e9e

Please sign in to comment.