Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify github workflow #197

Merged
merged 14 commits into from
Feb 28, 2024
77 changes: 47 additions & 30 deletions .github/workflows/build-release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,56 @@
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Build Release Assets
on:
workflow_dispatch:
on:
release:
types: [published]

jobs:
releases-matrix:
name: Release Zip
runs-on: ubuntu-latest
strategy:
matrix:
make_directive: [zip-x86_64, zip-arm64]
steps:
- uses: actions/checkout@v3

- name: set up Go
uses: actions/setup-go@v3
build-release-x86_64:
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: make zip
run: make ${{ matrix.make_directive }}

- name: upload artifact
env:
GH_TOKEN: ${{ secrets.RELEASE_ASSET_TOKEN }}
run: |
tag=$(gh release list --json tagName -q '.[0].tagName')
file=/tmp/newrelic-lambda-extension.arm64.zip
if [ -f /tmp/newrelic-lambda-extension.x86_64.zip ];then
file=/tmp/newrelic-lambda-extension.x86_64.zip
fi
go-version: '1.20'
cache-dependency-path: |
subdir/go.sum
tools/go.sum
- name: Build and archive x86_64 distribution
run: make zip-x86_64
- name: Publish x86_64 release on GitHub
uses: softprops/action-gh-release@v1
with:
files: /tmp/newrelic-lambda-extension.x86_64.zip
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}
name: "Release ${{ github.ref_name }}"
draft: false
prerelease: false

echo "uploading $file to release $tag"
gh release upload "$tag" "$file"


build-release-arm:
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
cache-dependency-path: |
subdir/go.sum
tools/go.sum
- name: Build and archive arm distribution
run: make zip-arm64
- name: Publish zip-arm64 release on GitHub
uses: softprops/action-gh-release@v1
with:
files: /tmp/newrelic-lambda-extension.arm64.zip
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}
name: "Release ${{ github.ref_name }}"
draft: false
prerelease: false
52 changes: 52 additions & 0 deletions .github/workflows/build-test-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow will test and run code coverage for the golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Build Test Coverage
on:
pull_request:
push:


env:
TEST_RESULTS: /tmp/test-results

jobs:
build-test:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
cache-dependency-path: |
subdir/go.sum
tools/go.sum
- name: Create test directory
run: mkdir -p $TEST_RESULTS
- name: Install gotestsum
run: go install gotest.tools/gotestsum@latest
- name: Run unit tests
run: |
PACKAGE_NAMES=$(go list ./... | xargs)
gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES
- name: Run build
run: make build


coverage:
runs-on: ubuntu-20.04
needs: build-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: true
- name: Generate coverage report
run: make coverage
- name: Upload coverage report
run: bash -c "$(curl -s https://codecov.io/bash)"
Loading