diff --git a/.github/workflows/on_push_pr_fake_prerelease.yaml b/.github/workflows/on_push_pr_fake_prerelease.yaml new file mode 100644 index 0000000..77a0bbc --- /dev/null +++ b/.github/workflows/on_push_pr_fake_prerelease.yaml @@ -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 }} diff --git a/.github/workflows/on_push_pr_no_fake_prerelease.yaml b/.github/workflows/on_push_pr_no_fake_prerelease.yaml new file mode 100644 index 0000000..c8bcadd --- /dev/null +++ b/.github/workflows/on_push_pr_no_fake_prerelease.yaml @@ -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 }} diff --git a/.github/workflows/static_analysis.yaml b/.github/workflows/static_analysis.yaml new file mode 100644 index 0000000..a5ded49 --- /dev/null +++ b/.github/workflows/static_analysis.yaml @@ -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 diff --git a/.github/workflows/test_build_nix.yaml b/.github/workflows/test_build_nix.yaml new file mode 100644 index 0000000..b9ecd68 --- /dev/null +++ b/.github/workflows/test_build_nix.yaml @@ -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 diff --git a/.github/workflows/test_build_windows.yaml b/.github/workflows/test_build_windows.yaml new file mode 100644 index 0000000..468d2fa --- /dev/null +++ b/.github/workflows/test_build_windows.yaml @@ -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" diff --git a/.github/workflows/test_integration_nix.yaml b/.github/workflows/test_integration_nix.yaml new file mode 100644 index 0000000..d7c53be --- /dev/null +++ b/.github/workflows/test_integration_nix.yaml @@ -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 diff --git a/.github/workflows/test_nix.yaml b/.github/workflows/test_nix.yaml new file mode 100644 index 0000000..0fe4f93 --- /dev/null +++ b/.github/workflows/test_nix.yaml @@ -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 diff --git a/.github/workflows/test_windows.yaml b/.github/workflows/test_windows.yaml new file mode 100644 index 0000000..7aaed26 --- /dev/null +++ b/.github/workflows/test_windows.yaml @@ -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