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

ci: add lint, pr, and release workflows #4

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Which configuration does this action use? It would make sense to make all the repos converge in the same linter configuration. I thought we did that for some repos when updating the makefiles etc, but that does not seem to be the case. If we want to do we could copy the one from sm-alerts repo, which I believe is the one that has been reviewed more recently.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ka3de Right now it is using the golangci defaults, it would be good to configure it. Feel free to open a PR with that config!

with:
only-new-issues: true
args: --timeout=5m # 1m is not enough, experimentally.
41 changes: 41 additions & 0 deletions .github/workflows/push-pr-release.yaml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.