Skip to content

Commit

Permalink
feat(ci/cd): include release toolkit (#72)
Browse files Browse the repository at this point in the history
* feat(ci/cd): include release toolkit

Co-authored-by: Juan Manuel "Kang" Pérez <[email protected]>

---------

Co-authored-by: Juan Manuel "Kang" Pérez <[email protected]>
  • Loading branch information
paologallinaharbur and kang-makes authored Oct 16, 2023
1 parent ba93daf commit e87648b
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 39 deletions.
5 changes: 5 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"github>newrelic/coreint-automation:renovate-base.json5"
]
}
44 changes: 14 additions & 30 deletions .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Prerelease pipeline
name: Create prerelease artifacts

on:
release:
Expand All @@ -15,20 +15,6 @@ env:
TAG: ${{ github.event.release.tag_name }}

jobs:
snyk:
name: Run security checks via snyk
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.OHAI_DOCKER_HUB_ID }}
password: ${{ secrets.OHAI_DOCKER_HUB_PASSWORD }}
- name: Scan code for vulnerabilities
env:
SNYK_TOKEN: ${{ secrets.COREINT_SNYK_TOKEN }}
run: make ci/snyk-test

test-nix:
name: Run unit tests on *Nix
Expand Down Expand Up @@ -68,7 +54,7 @@ jobs:
prerelease:
name: Build binary for *Nix/Win, create archives for *Nix/Win, create packages for *Nix, upload all artifacts into GH Release assets
runs-on: ubuntu-20.04
needs: [test-nix, test-windows, snyk]
needs: [test-nix, test-windows]
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
Expand All @@ -82,13 +68,6 @@ jobs:
GPG_MAIL: '[email protected]'
GPG_PASSPHRASE: ${{ secrets.OHAI_GPG_PASSPHRASE }}
GPG_PRIVATE_KEY_BASE64: ${{ secrets.OHAI_GPG_PRIVATE_KEY_BASE64 }} # base64 encoded
- name: Notify failure via Slack
if: ${{ failure() }}
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.REPO_FULL_NAME }}`: prerelease pipeline failed."
- name: Test package installability
uses: newrelic/integrations-pkg-test-action/linux@v1
with:
Expand Down Expand Up @@ -139,13 +118,6 @@ jobs:
shell: bash
run: |
build/windows/upload_msi.sh ${INTEGRATION} ${{ matrix.goarch }} ${TAG}
- name: Notify failure via Slack
if: ${{ failure() }}
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.REPO_FULL_NAME }}`: prerelease pipeline failed."
publish-to-s3:
name: Send release assets to S3
Expand Down Expand Up @@ -190,3 +162,15 @@ jobs:
packageLocation: repo
stagingRepo: true
upgrade: false

notify-failure:
if: ${{ always() && failure() }}
needs: [test-nix, test-windows, prerelease, package-win, publish-to-s3]
runs-on: ubuntu-latest
steps:
- name: Notify failure via Slack
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.ORIGINAL_REPO_NAME }}`: [prerelease pipeline failed](${{ github.server_url }}/${{ env.ORIGINAL_REPO_NAME }}/actions/runs/${{ github.run_id }})."
5 changes: 4 additions & 1 deletion .github/workflows/push_pr.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: Push/PR pipeline
name: Push/PR

on:
push:
branches:
- main
- master
- renovate/**
pull_request:

env:
Expand All @@ -29,6 +30,8 @@ jobs:
continue-on-error: ${{ github.event_name != 'pull_request' }}
with:
only-new-issues: true
- name: Check if CHANGELOG is valid
uses: newrelic/release-toolkit/validate-markdown@v1

snyk:
name: Run security checks via snyk
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release pipeline
name: Create release artifacts

on:
release:
Expand Down Expand Up @@ -57,4 +57,16 @@ jobs:
tag: ${{ env.TAG }}
integration: 'nri-${{ env.INTEGRATION }}' # Required, with nri- prefix
packageLocation: repo
upgrade: false
upgrade: false

notify-failure:
if: ${{ always() && failure() }}
needs: [publish-to-s3]
runs-on: ubuntu-latest
steps:
- name: Notify failure via Slack
uses: archive/github-actions-slack@master
with:
slack-bot-user-oauth-access-token: ${{ secrets.COREINT_SLACK_TOKEN }}
slack-channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack-text: "❌ `${{ env.ORIGINAL_REPO_NAME }}`: [release pipeline failed](${{ github.server_url }}/${{ env.ORIGINAL_REPO_NAME }}/actions/runs/${{ github.run_id }})."
51 changes: 51 additions & 0 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Security Scan

on:
push:
branches:
- master
- main
- renovate/**
pull_request:
schedule:
- cron: "0 3 * * *"

jobs:
trivy:
name: Trivy security scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/[email protected]
if: ${{ ! github.event.schedule }} # Do not run inline checks when running periodically
with:
scan-type: fs
ignore-unfixed: true
exit-code: 1
severity: 'HIGH,CRITICAL'
skip-dirs: 'build'
# test private key
skip-files: 'tests/integration/tls_cert/redis.key'

- name: Run Trivy vulnerability scanner sarif output
uses: aquasecurity/[email protected]
if: ${{ github.event.schedule }} # Generate sarif when running periodically
with:
scan-type: fs
ignore-unfixed: true
severity: 'HIGH,CRITICAL'
format: 'template'
template: '@/contrib/sarif.tpl'
output: 'trivy-results.sarif'
skip-dirs: 'build'
# test private key
skip-files: 'tests/integration/tls_cert/redis.key'

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: ${{ github.event.schedule }} # Upload sarif when running periodically
with:
sarif_file: 'trivy-results.sarif'
20 changes: 20 additions & 0 deletions .github/workflows/trigger_prerelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Trigger prerelease creation

# This workflow triggers a prerelease creation with changelog and the release notes created by the release toolkit.
# This workflow should be triggered merely from the default branch.
# If you wish to be 100% free creating a prerelease, just create it manually.

on:
workflow_dispatch:
schedule:
- cron: "0 5 * * 4"

jobs:
prerelease:
uses: newrelic/coreint-automation/.github/workflows/trigger_prerelease.yaml@v1
secrets:
bot_token: ${{ secrets.COREINT_BOT_TOKEN }}
slack_channel: ${{ secrets.COREINT_SLACK_CHANNEL }}
slack_token: ${{ secrets.COREINT_SLACK_TOKEN }}
with:
rt-included-files: go.mod,go.sum,build/Dockerfile
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ vendor/

# build files
src/versioninfo.json
src/resource.syso
src/resource.syso


# Release toolkit
CHANGELOG.partial.md
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Change Log
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

Unreleased section should follow [Release Toolkit](https://github.com/newrelic/release-toolkit#render-markdown-and-update-markdown)

## Unreleased

## 2.7.1 (2023-08-22)
# Fixed
### Fixed
- Removes config validation that prevents to run the integration without a custom CA certificates

## 2.7.0 (2023-06-06)
# Changed
### Changed
- Upgrade Go version to 1.20

## 2.6.0 (2022-08-01)
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ compile:
@echo "=== $(INTEGRATION) === [ compile ]: Building $(BINARY_NAME)..."
@go build -o bin/$(BINARY_NAME) $(GO_FILES)

# rt-update-changelog runs the release-toolkit run.sh script by piping it into bash to update the CHANGELOG.md.
# It also passes down to the script all the flags added to the make target. To check all the accepted flags,
# see: https://github.com/newrelic/release-toolkit/blob/main/contrib/ohi-release-notes/run.sh
# e.g. `make rt-update-changelog -- -v`
rt-update-changelog:
curl "https://raw.githubusercontent.com/newrelic/release-toolkit/v1/contrib/ohi-release-notes/run.sh" | bash -s -- $(filter-out $@,$(MAKECMDGOALS))

# Include thematic Makefiles
include $(CURDIR)/build/ci.mk
include $(CURDIR)/build/release.mk

.PHONY: all build clean compile test
.PHONY: all build clean compile test rt-update-changelog
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20-buster
FROM golang:1.20.6-bookworm

ARG GH_VERSION='1.9.2'

Expand Down

0 comments on commit e87648b

Please sign in to comment.