-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add e2e tests (k6) and improve the CI (#588)
- Loading branch information
1 parent
2e0b0d2
commit 72ef89e
Showing
16 changed files
with
620 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,18 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- {uses: gacts/github-slug@v1, id: slug} | ||
- id: values | ||
run: echo "binary-name=webhook-tester-${{ matrix.os }}-${{ matrix.arch }}`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`" >> $GITHUB_OUTPUT | ||
run: | | ||
majorMinorPatch="${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}" | ||
echo "version=${majorMinorPatch}" >> $GITHUB_OUTPUT | ||
echo "binary-name=webhook-tester-${{ matrix.os }}-${{ matrix.arch }}`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`" >> $GITHUB_OUTPUT | ||
echo "deb-name=webhook-tester_${majorMinorPatch}-1_${{ matrix.arch }}" >> $GITHUB_OUTPUT | ||
# build the frontend | ||
- uses: actions/setup-node@v4 | ||
with: {node-version: 22, cache: 'npm', cache-dependency-path: ./web/package-lock.json} | ||
- run: npm --prefix "$NPM_PREFIX" install --no-audit | ||
- run: npm --prefix "$NPM_PREFIX" run generate | ||
- run: npm --prefix "$NPM_PREFIX" run build | ||
with: {node-version-file: ./web/package.json, cache: 'npm', cache-dependency-path: ./web/package-lock.json} | ||
- run: | | ||
npm --prefix "$NPM_PREFIX" install --no-audit | ||
npm --prefix "$NPM_PREFIX" run generate | ||
npm --prefix "$NPM_PREFIX" run build | ||
# build the backend | ||
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}} | ||
- run: go install "github.com/oapi-codegen/oapi-codegen/v2/cmd/[email protected]" | ||
|
@@ -45,6 +50,24 @@ jobs: | |
file: ${{ steps.values.outputs.binary-name }} | ||
asset_name: ${{ steps.values.outputs.binary-name }} | ||
tag: ${{ github.ref }} | ||
# build a Debian package | ||
- if: matrix.os == 'linux' && matrix.arch == 'amd64' | ||
env: | ||
PKG_NAME: ${{ steps.values.outputs.deb-name }} | ||
run: | | ||
mkdir -p ${{ env.PKG_NAME }}/usr/local/bin ${{ env.PKG_NAME }}/DEBIAN | ||
cp ${{ steps.values.outputs.binary-name }} ${{ env.PKG_NAME }}/usr/local/bin/webhook-tester | ||
echo -e "Package: webhook-tester\nVersion: ${{ steps.values.outputs.version }}" > ${{ env.PKG_NAME }}/DEBIAN/control | ||
echo -e "Architecture: ${{ matrix.arch }}\nMaintainer: ${{ github.actor }}" >> ${{ env.PKG_NAME }}/DEBIAN/control | ||
echo -e "Description: Powerful tool for testing WebHooks and more" >> ${{ env.PKG_NAME }}/DEBIAN/control | ||
dpkg-deb --build --root-owner-group ${{ env.PKG_NAME }} | ||
- if: matrix.os == 'linux' && matrix.arch == 'amd64' | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: ${{ steps.values.outputs.deb-name }}.deb | ||
asset_name: ${{ steps.values.outputs.binary-name }}.deb | ||
tag: ${{ github.ref }} | ||
|
||
build-docker-image: | ||
name: Build the docker image | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: {node-version: 22, cache: 'npm', cache-dependency-path: ./web/package-lock.json} | ||
with: {node-version-file: ./web/package.json, cache: 'npm', cache-dependency-path: ./web/package-lock.json} | ||
- run: npm --prefix "$NPM_PREFIX" install -dd --no-audit | ||
- run: npm --prefix "$NPM_PREFIX" run generate | ||
- run: npm --prefix "$NPM_PREFIX" run lint | ||
|
@@ -63,13 +63,18 @@ jobs: | |
- uses: actions/checkout@v4 | ||
- {uses: gacts/github-slug@v1, id: slug} | ||
- id: values | ||
run: echo "binary-name=webhook-tester-${{ matrix.os }}-${{ matrix.arch }}`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`" >> $GITHUB_OUTPUT | ||
run: | | ||
majorMinorPatch="${{ steps.slug.outputs.version-major }}.${{ steps.slug.outputs.version-minor }}.${{ steps.slug.outputs.version-patch }}" | ||
echo "version=${majorMinorPatch}" >> $GITHUB_OUTPUT | ||
echo "binary-name=webhook-tester-${{ matrix.os }}-${{ matrix.arch }}`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`" >> $GITHUB_OUTPUT | ||
echo "deb-name=webhook-tester_${majorMinorPatch}-1_${{ matrix.arch }}" >> $GITHUB_OUTPUT | ||
# build the frontend | ||
- uses: actions/setup-node@v4 | ||
with: {node-version: 22, cache: 'npm', cache-dependency-path: ./web/package-lock.json} | ||
- run: npm --prefix "$NPM_PREFIX" install --no-audit | ||
- run: npm --prefix "$NPM_PREFIX" run generate | ||
- run: npm --prefix "$NPM_PREFIX" run build | ||
with: {node-version-file: ./web/package.json, cache: 'npm', cache-dependency-path: ./web/package-lock.json} | ||
- run: | | ||
npm --prefix "$NPM_PREFIX" install --no-audit | ||
npm --prefix "$NPM_PREFIX" run generate | ||
npm --prefix "$NPM_PREFIX" run build | ||
# build the backend | ||
- {uses: actions/setup-go@v5, with: {go-version-file: go.mod}} | ||
- run: go install "github.com/oapi-codegen/oapi-codegen/v2/cmd/[email protected]" | ||
|
@@ -78,17 +83,63 @@ jobs: | |
GOOS: ${{ matrix.os }} | ||
GOARCH: ${{ matrix.arch }} | ||
CGO_ENABLED: 0 | ||
LDFLAGS: -s -w -X gh.tarampamp.am/webhook-tester/v2/internal/version.version=v0.0.0@${{ steps.slug.outputs.commit-hash-short }} | ||
LDFLAGS: -s -w -X gh.tarampamp.am/webhook-tester/v2/internal/version.version=v${{ steps.values.outputs.version }}@${{ steps.slug.outputs.commit-hash-short }} | ||
run: go build -trimpath -ldflags "$LDFLAGS" -o ./${{ steps.values.outputs.binary-name }} ./cmd/webhook-tester/ | ||
# try to run the binary | ||
- if: matrix.os == runner.os && matrix.arch == 'amd64' | ||
- if: matrix.os == runner.os && matrix.arch == 'amd64' # try to run the binary | ||
run: ./${{ steps.values.outputs.binary-name }} -h | ||
# upload the binary | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ steps.values.outputs.binary-name }} | ||
path: ./${{ steps.values.outputs.binary-name }} | ||
if-no-files-found: error | ||
retention-days: 7 | ||
# build a Debian package | ||
- if: matrix.os == 'linux' && matrix.arch == 'amd64' | ||
env: | ||
PKG_NAME: ${{ steps.values.outputs.deb-name }} | ||
run: | | ||
mkdir -p ${{ env.PKG_NAME }}/usr/local/bin ${{ env.PKG_NAME }}/DEBIAN | ||
cp ${{ steps.values.outputs.binary-name }} ${{ env.PKG_NAME }}/usr/local/bin/webhook-tester | ||
echo -e "Package: webhook-tester\nVersion: ${{ steps.values.outputs.version }}" > ${{ env.PKG_NAME }}/DEBIAN/control | ||
echo -e "Architecture: ${{ matrix.arch }}\nMaintainer: ${{ github.actor }}" >> ${{ env.PKG_NAME }}/DEBIAN/control | ||
echo -e "Description: Powerful tool for testing WebHooks and more" >> ${{ env.PKG_NAME }}/DEBIAN/control | ||
dpkg-deb --build --root-owner-group ${{ env.PKG_NAME }} | ||
- if: matrix.os == 'linux' && matrix.arch == 'amd64' | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ steps.values.outputs.binary-name }}.deb | ||
path: ./${{ steps.values.outputs.deb-name }}.deb | ||
if-no-files-found: error | ||
retention-days: 7 | ||
|
||
e2e-test: | ||
name: End-to-end tests | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
storage-driver: [memory, redis] | ||
pubsub-driver: [memory, redis] | ||
services: | ||
redis: | ||
image: docker.io/library/redis:7-alpine | ||
ports: ['6379:6379/tcp'] | ||
options: --health-cmd "redis-cli ping" --health-interval 3s --health-timeout 2s --health-retries 3 | ||
needs: [build-app] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- {uses: actions/download-artifact@v4, with: {name: webhook-tester-linux-amd64}} | ||
- run: | # start the server in the background | ||
chmod +x ./webhook-tester-linux-amd64 | ||
./webhook-tester-linux-amd64 start --port 8081 \ | ||
--storage-driver "${{ matrix.storage-driver }}" \ | ||
--pubsub-driver "${{ matrix.pubsub-driver }}" \ | ||
--redis-dsn "redis://127.0.0.1:6379/0" & | ||
- uses: grafana/setup-k6-action@v1 | ||
- uses: grafana/run-k6-action@v1 | ||
env: {BASE_URL: 'http://127.0.0.1:8081'} | ||
with: {path: ./tests/k6/run.js} | ||
|
||
build-docker-image: | ||
name: Build the docker image | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.