From 68aedf7a2751cd84b495e86feaf19cd90214033c Mon Sep 17 00:00:00 2001 From: Nadia Santalla Date: Thu, 5 Sep 2024 14:46:12 +0200 Subject: [PATCH 1/2] ci: add lint and build-release workflows --- .github/workflows/lint.yaml | 16 ++++++++++ .github/workflows/push-pr-release.yaml | 41 ++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/lint.yaml create mode 100644 .github/workflows/push-pr-release.yaml diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 0000000..cac79db --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,16 @@ +name: Lint + +on: + pull_request: {} + +jobs: + golangci: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + only-new-issues: true + args: --timeout=5m # 1m is not enough, experimentally. diff --git a/.github/workflows/push-pr-release.yaml b/.github/workflows/push-pr-release.yaml new file mode 100644 index 0000000..e5912ce --- /dev/null +++ b/.github/workflows/push-pr-release.yaml @@ -0,0 +1,41 @@ +name: Build + +on: + pull_request: {} + release: + types: [ published ] + +# Needed to upload assets to releases. +permissions: + contents: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + strategy: + matrix: + goos: [ linux ] + goarch: [ amd64, arm64 ] + steps: + - uses: actions/checkout@v4 + - name: Extract k6 version from go.mod + id: version + run: |- + k6version=$(grep -e go.k6.io go.mod | cut -d' ' -f 2) + echo "Detected k6 version: ${k6version}" + echo "k6=${k6version}" >> $GITHUB_OUTPUT + - name: Build with xk6 + run: |- + docker run --rm -i -u "$(id -u):$(id -g)" -v "${PWD}:/xk6" \ + -e "GOOS=${{ matrix.goos }}" -e "GOARCH=${{ matrix.goarch }}" \ + grafana/xk6 build ${{ steps.version.outputs.k6 }} \ + --output "dist/sm-k6-${{ matrix.goos }}-${{ matrix.goarch }}" \ + --with sm=. + + - name: Upload artifact to release + if: github.event_name == 'release' + env: + GH_TOKEN: ${{ github.token }} + run: |- + gh release upload "${{ github.ref_name }}" dist/* --clobber From c9aaab37a0bbe26e3eec72b8d679f9d4bba72c85 Mon Sep 17 00:00:00 2001 From: Nadia Santalla Date: Tue, 8 Oct 2024 12:23:44 +0200 Subject: [PATCH 2/2] README: briefly mention how to build or release this project --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 2bd1db9..ac00946 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ # xk6-sm Output k6 extension used by the [synthetic monitoring agent](https://github.com/grafana/synthetic-monitoring-agent). + +## Build + +Use [xk6](https://github.com/grafana/xk6). See the CI/CD pipelines for a full example of a build command. + +## Release process + +Create a release using the GitHub UI or `gh create release`. A CI/CD pipeline will build the artifacts and attach them to the release.