Skip to content

Commit

Permalink
chore: add push pr workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsanmi committed Jan 18, 2024
1 parent 20ae56e commit 438f446
Show file tree
Hide file tree
Showing 8 changed files with 344 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/on_push_pr_fake_prerelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Push/PR fake prereleases

on:
workflow_call:
inputs:
run_static_analysis:
required: false
type: boolean
default: true
run_test_nix:
required: false
type: boolean
default: true
run_test_windows:
required: false
type: boolean
default: true
run_integration_nix:
required: false
type: boolean
default: true
run_test_build_nix:
required: false
type: boolean
default: true
run_test_build_windows:
required: false
type: boolean
default: true

jobs:
static-analysis:
if: ${{ inputs.run_static_analysis }}
uses: ./.github/workflows/static_analysis.yaml
with:
run_job: ${{ inputs.run_static_analysis }}

test-nix:
if: ${{ inputs.run_test_nix }}
uses: ./.github/workflows/test_nix.yaml
with:
run_job: ${{ inputs.run_test_nix }}

test-windows:
if: ${{ inputs.run_test_windows }}
uses: ./.github/workflows/test_windows.yaml
with:
run_job: ${{ inputs.run_test_windows }}

test-integration-nix:
if: ${{ inputs.run_integration_nix }}
uses: ./.github/workflows/test_integration_nix.yaml
with:
run_job: ${{ inputs.run_integration_nix }}

test-build-nix:
if: ${{ inputs.run_test_build_nix }}
uses: ./.github/workflows/test_build_nix.yaml
with:
run_job: ${{ inputs.run_test_build_nix }}

test-build-windows:
if: ${{ inputs.run_test_build_nix }}
uses: ./.github/workflows/test_build_windows.yaml
with:
run_job: ${{ inputs.run_test_build_windows }}
56 changes: 56 additions & 0 deletions .github/workflows/on_push_pr_no_fake_prerelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Push/PR no fake prereleases

on:
workflow_call:
inputs:
run_static_analysis:
required: false
type: boolean
default: true
run_test_nix:
required: false
type: boolean
default: true
run_test_windows:
required: false
type: boolean
default: true
run_integration_nix:
required: false
type: boolean
default: true
run_test_build_nix:
required: false
type: boolean
default: true

jobs:
static-analysis:
if: ${{ inputs.run_static_analysis }}
uses: ./.github/workflows/static_analysis.yaml
with:
run_job: ${{ inputs.run_static_analysis }}

test-nix:
if: ${{ inputs.run_test_nix }}
uses: ./.github/workflows/test_nix.yaml
with:
run_job: ${{ inputs.run_test_nix }}

test-windows:
if: ${{ inputs.run_test_windows }}
uses: ./.github/workflows/test_windows.yaml
with:
run_job: ${{ inputs.run_test_windows }}

test-integration-nix:
if: ${{ inputs.run_integration_nix }}
uses: ./.github/workflows/test_integration_nix.yaml
with:
run_job: ${{ inputs.run_integration_nix }}

test-build-nix:
if: ${{ inputs.run_test_build_nix }}
uses: ./.github/workflows/test_build_nix.yaml
with:
run_job: ${{ inputs.run_test_build_nix }}
23 changes: 23 additions & 0 deletions .github/workflows/static_analysis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Static Analysis

on:
workflow_call:

jobs:
static-analysis:
name: Run all static analysis checks
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: newrelic/newrelic-infra-checkers@v1
- name: Semgrep
uses: returntocorp/semgrep-action@v1
with:
auditOn: push
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
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
26 changes: 26 additions & 0 deletions .github/workflows/test_build_nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Build *Nix

on:
workflow_call:
inputs:
docker_hub_id:
required: true
type: string
docker_hub_password:
required: true
type: string

jobs:
test-build-nix:
name: Test binary compilation for all platforms:arch
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
if: ${{ env.DOCKER_LOGIN_AVAILABLE }}
uses: docker/login-action@v2
with:
username: ${{ inputs.docker_hub_id }}
password: ${{ inputs.docker_hub_password }}
- name: Build all platforms:arch
run: make ci/build
70 changes: 70 additions & 0 deletions .github/workflows/test_build_windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Test Build Windows

on:
workflow_call:
inputs:
run_job:
required: false
type: boolean
default: true
pfx_certificate_base64:
required: true
type: string
pfx_passphrase:
required: true
type: string
original_repo_name:
required: true
type: string
tag:
required: true
type: string

jobs:
test-build-windows:
if: ${{ inputs.run_job }}
name: Create MSI
runs-on: windows-latest
needs: [ test-build-nix ]
env:
GOPATH: ${{ github.workspace }}
PFX_CERTIFICATE_BASE64: ${{ inputs.pfx_certificate_base64 }}
PFX_CERTIFICATE_DESCRIPTION: 'New Relic'
PFX_PASSPHRASE: ${{ inputs.pfx_passphrase }}
ORIGINAL_REPO_NAME: ${{ inputs.original_repo_name }}
TAG: ${{ inputs.tag }}
defaults:
run:
working-directory: src/github.com/${{ env.ORIGINAL_REPO_NAME }}
strategy:
matrix:
goarch: [ amd64,386 ]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
path: src/github.com/${{ env.ORIGINAL_REPO_NAME }}
- shell: bash
run: git tag "$TAG"

- name: Download artifact from previous job
uses: actions/download-artifact@v3
with:
name: windows-packages
path: src/github.com/${{ env.ORIGINAL_REPO_NAME }}/dist/

- name: Get PFX certificate from GH secrets
shell: bash
run: |
if [ -z "$PFX_CERTIFICATE_BASE64" ]; then
echo NO_SIGN=true >> $GITHUB_ENV
else
printf "%s" "$PFX_CERTIFICATE_BASE64" | base64 -d - > wincert.pfx
fi
- name: Extract .exe
shell: pwsh
run: build\windows\extract_exe.ps1 "$env:INTEGRATION" ${{ matrix.goarch }} "$env:TAG"
- name: Create MSI
shell: pwsh
run: build\windows\package_msi.ps1 -integration "$env:INTEGRATION" -arch ${{ matrix.goarch }} -tag "$env:TAG" -pfx_passphrase "$env:PFX_PASSPHRASE" -pfx_certificate_description "$env:PFX_CERTIFICATE_DESCRIPTION"
44 changes: 44 additions & 0 deletions .github/workflows/test_integration_nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Integration Tests on *Nix

on:
workflow_call:
inputs:
run_job:
required: false
type: boolean
default: true
docker_hub_id:
required: true
type: string
docker_hub_password:
required: true
type: string
original_repo_name:
required: true
type: string

jobs:
test-integration-nix:
if: ${{ inputs.run_job }}
name: Run integration tests on *Nix
runs-on: ubuntu-20.04
env:
ORIGINAL_REPO_NAME: ${{ inputs.original_repo_name }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 1
path: src/github.com/${{ env.ORIGINAL_REPO_NAME }}
- name: Install Go
uses: actions/setup-go@v4
with:
go-version-file: "src/github.com/${{ env.ORIGINAL_REPO_NAME }}/go.mod"
- name: Login to DockerHub
if: ${{ env.DOCKER_LOGIN_AVAILABLE }}
uses: docker/login-action@v2
with:
username: ${{ inputs.docker_hub_id }}
password: ${{ inputs.docker_hub_password }}
- name: Integration test
run: make integration-test
26 changes: 26 additions & 0 deletions .github/workflows/test_nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Unit Tests on *Nix

on:
workflow_call:
inputs:
docker_hub_id:
required: true
type: string
docker_hub_password:
required: true
type: string

jobs:
test-nix:
name: Run unit tests on *Nix
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
if: ${{ env.DOCKER_LOGIN_AVAILABLE }}
uses: docker/login-action@v2
with:
username: ${{ inputs.docker_hub_id }}
password: ${{ inputs.docker_hub_password }}
- name: Unit tests
run: make ci/test
33 changes: 33 additions & 0 deletions .github/workflows/test_windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Unit Tests on Windows

on:
workflow_call:
inputs:
run_job:
required: false
type: boolean
default: true
original_repo_name:
required: true
type: string

jobs:
test-windows:
if: ${{ inputs.run_job }}
name: Run unit tests on Windows
runs-on: windows-2019
env:
ORIGINAL_REPO_NAME: ${{ inputs.original_repo_name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: src/github.com/${{ inputs.original_repo_name }}
- name: Install Go
uses: actions/setup-go@v4
with:
go-version-file: "src/github.com/${{ inputs.original_repo_name }}/go.mod"
- name: Running unit tests
shell: pwsh
run: |
.\build\windows\unit_tests.ps1

0 comments on commit 438f446

Please sign in to comment.