Skip to content

Commit

Permalink
Merge all workflow updates (#6)
Browse files Browse the repository at this point in the history
* feat(actions): added release action

* feat(actions): add write all permission

* feat(build): add lambda Dockerfile

* feat(build): add goreleaser for lambda

* feat(build): skip changelog for docker build

* feat(actions): do not run build/repolinter on all push

* feat(git): add git pre-commit hook

* feat(build): Updated to work with pre-commit

* feat(build): add pre-commit

* feat(build): add gobin to path

* feat(build): added commitlint

* feat(build): run commitlint in validate action

* feat(build): set fetch-depth to 2

* ci: add pull request template
  • Loading branch information
sdewitt-newrelic authored May 10, 2023
1 parent 08ead4c commit f9f4be5
Show file tree
Hide file tree
Showing 16 changed files with 209 additions and 72 deletions.
2 changes: 0 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ max_line_length = 80
[*.md]
max_line_length = 0
trim_trailing_whitespace = false


27 changes: 0 additions & 27 deletions .github/ISSUE_TEMPLATE/enhancement.md

This file was deleted.

17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

### Feature Description
A clear and concise description of the feature you want or need.

### Describe Alternatives
A clear and concise description of any alternative solutions or features you've considered. Are there examples you could link us to?

### Additional context
Add any other context here.
28 changes: 28 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Description

Please include a summary of the changes and the related issue.

## Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

- [ ] Test A
- [ ] Test B

# Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
11 changes: 4 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# 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
name: Build & Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
on: [pull_request]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repo
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will release a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Release

permissions: write-all

on:
push:
branches: [ "main" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v3

- name: Generate new tag
uses: obfu5c8/action-svu@v1
id: generate_next_version
with:
force-increment: true

- name: Tag latest commit
run: |
git tag ${{ steps.generate_next_version.outputs.version }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7 changes: 5 additions & 2 deletions .github/workflows/repolinter.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# NOTE: This file should always be named `repolinter.yml` to allow
# workflow_dispatch to work properly
name: Repolinter Action
name: Repolinter

# NOTE: This workflow will ONLY check the default branch!
# Currently there is no elegant way to specify the default
# branch in the event filtering, so branches are instead
# filtered in the "Test Default Branch" step.
on: [push, workflow_dispatch]
on: [pull_request, workflow_dispatch]

jobs:

repolint:
name: Run Repolinter
runs-on: ubuntu-latest
Expand All @@ -20,9 +21,11 @@ jobs:
script: |
const data = await github.repos.get(context.repo)
return data.data && data.data.default_branch === context.ref.split('/').slice(-1)[0]
- name: Checkout Self
if: ${{ steps.default-branch.outputs.result == 'true' }}
uses: actions/checkout@v2

- name: Run Repolinter
if: ${{ steps.default-branch.outputs.result == 'true' }}
uses: newrelic/repolinter-action@v1
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will validate a golang project

name: Validate

on: [push]

jobs:

lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Set up Go
uses: actions/setup-go@v3

- name: Set up Python
uses: actions/setup-python@v3

- name: Setup Node
uses: actions/setup-node@v3

- name: Add GOBIN to PATH
run: echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash

- name: Install staticcheck
run: "go install 'honnef.co/go/tools/cmd/staticcheck@latest'"

- name: Run pre-commit
uses: pre-commit/[email protected]

- name: Install commitlint
run: "npm install -g @commitlint/cli @commitlint/config-conventional"

- name: Lint last commit message
run: "commitlint --from HEAD~1 --to HEAD --verbose"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ config.yml

dist/
cf-params.json
.build.env
__tools/
37 changes: 37 additions & 0 deletions .goreleaser-lambda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy

builds:
- id: lambda
main: ./cmd/nr-entity-tag-sync-lambda/nr-entity-tag-sync-lambda.go
binary: nr-entity-tag-sync-lambda
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64

archives:
- format: binary

dockers:
- id: lambda-image
ids:
- lambda
image_templates:
- "{{ .Env.AWS_ECR_REPO_URI }}:latest"
- "{{ .Env.AWS_ECR_REPO_URI }}:{{ .Tag }}"
dockerfile: ./deployments/Dockerfile-lambda
extra_files:
- configs/config.yml

changelog:
skip: true

release:
disable: true
33 changes: 4 additions & 29 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,14 @@ builds:
- CGO_ENABLED=0
goos:
- linux
#- windows
#- darwin
- windows
- darwin
goarch:
- "386"
- amd64
- id: lambda
main: ./cmd/nr-entity-tag-sync-lambda/nr-entity-tag-sync-lambda.go
binary: nr-entity-tag-sync-lambda
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64

dockers:
- id: lambda-image
ids:
- lambda
image_templates:
- "{{ .Env.AWS_ECR_REPO_URI }}:latest"
- "{{ .Env.AWS_ECR_REPO_URI }}:{{ .Tag }}"
dockerfile: ./deployments/Dockerfile-lambda
extra_files:
- configs/config.yml

archives:
- format: tar.gz
builds:
- standalone
# this name template makes the OS and Arch compatible with the results of uname.
name_template: >-
{{ .ProjectName }}_
Expand All @@ -59,14 +38,10 @@ checksum:

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

# The lines beneath this are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_stages:
- commit
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-json
- id: check-shebang-scripts-are-executable
- id: check-yaml
exclude: cf-template.yaml
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/Bahjat/pre-commit-golang
rev: v1.0.3
hooks:
- id: go-vet
- id: go-unit-tests
- id: go-static-check # install https://staticcheck.io/docs/
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.5.0
hooks:
- id: commitlint
stages:
- commit-msg
additional_dependencies: ['@commitlint/config-conventional']
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] }
1 change: 0 additions & 1 deletion configs/config.sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ mappings:
sys_id: SNOW_CMDB_CI
environment: SNOW_ENVIRONMENT
sys_domain.value: SNOW_SYS_DOMAIN

2 changes: 1 addition & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Examples:

* https://github.com/kubernetes/helm/tree/master/scripts
* https://github.com/cockroachdb/cockroach/tree/master/scripts
* https://github.com/hashicorp/terraform/tree/master/scripts
* https://github.com/hashicorp/terraform/tree/master/scripts
2 changes: 0 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ Additional external test apps and test data. Feel free to structure the `/test`
Examples:

* https://github.com/openshift/origin/tree/master/test (test data is in the `/testdata` subdirectory)


0 comments on commit f9f4be5

Please sign in to comment.