Skip to content

Commit e9a4ded

Browse files
committed
feat: add GithubAction for interacting with the lease service (#10)
* feat: add github action for interacting with the merge-queue Note: this is missing test-cases, which will likely be hard to implement. Will have a look - if all goes wrong we might be able to add a full-loop E2E test Signed-off-by: Matthias Riegler <[email protected]> * chore: compile github actions Signed-off-by: Matthias Riegler <[email protected]> * feat: add ahead_by log Signed-off-by: Matthias Riegler <[email protected]> * chore: cleanup package.json Signed-off-by: Matthias Riegler <[email protected]> * feat: add retries Signed-off-by: Matthias Riegler <[email protected]> * feat: add uuid header propagation for basic authentication Note: this needs to be addressed in the future Signed-off-by: Matthias Riegler <[email protected]> * chore: gen-workflows Signed-off-by: Matthias Riegler <[email protected]> * fix: run pre-commit Signed-off-by: Matthias Riegler <[email protected]> * feat: allow atomic operations Signed-off-by: Matthias Riegler <[email protected]> * fix: prod deploy target Signed-off-by: Matthias Riegler <[email protected]> * fix: pre-commit Signed-off-by: Matthias Riegler <[email protected]> * chore: rotate uuid for prod Signed-off-by: Matthias Riegler <[email protected]> --------- Signed-off-by: Matthias Riegler <[email protected]> Signed-off-by: Matthias Riegler <[email protected]>
1 parent 3b24aef commit e9a4ded

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ dist/
22

33
kubernetes/vendor
44
hack/workflows/vendor
5+
node_modules/

Makefile

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,17 @@ e2e: ## run e2e tests
3131
go run github.com/onsi/ginkgo/v2/ginkgo@$(E2E_GINKGO_VERSION)
3232

3333
.PHONY: build
34-
build: ## build the application (server & cli)
34+
build: build-server build-gha
35+
36+
37+
.PHONY: build-server
38+
build-server: ## build the application (server)
3539
goreleaser build --snapshot --clean --single-target
3640

41+
.PHONY: build-gha
42+
build-gha: ## build the github action JS bundle(s)
43+
npm ci
44+
npm run build
45+
3746
run-server: build ## run the server with an example config
3847
./dist/server_${GOOS}_${GOARCH}/server -config=hack/example-server-config.yaml -log-json=false -log-debug=$(DEBUG) -port=$(LEASE_SERVICE_PORT)

README.md

+42-2
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,45 @@ sequenceDiagram
185185

186186

187187
### GithubAction
188-
> :warning: WIP
189-
The GithubAction component of this repo interacts with the LeaseProvider and determines the priority of each run based on the commits ahead of the baseRef.
188+
The GithubAction component of this repo interacts with the LeaseProvider and determines the priority of each run based on the commits ahead of the base.
189+
It has two stages:
190+
1. Acquiring a lease
191+
2. Releasing a lease when (1) has been successful, reporting the Github action job status
192+
193+
An example workflow can look like this:
194+
```yaml
195+
on:
196+
# Trigger on PRs; here we just skip
197+
pull_request:
198+
branches: [ main ]
199+
# Trigger on the merge group event
200+
merge_group:
201+
branches: [ main ]
202+
types: [ checks_requested ]
203+
204+
jobs:
205+
access-shared-resource:
206+
runs-on: ubuntu-latest
207+
if: ${{ github.event_name == 'merge_group' }}
208+
steps:
209+
- name: Checkout Plugin Repository
210+
uses: actions/checkout@v3
211+
- name: Aquire lease
212+
id: acquire_lease
213+
uses: ankorstore/gh-action-mq-lease-service@main
214+
with:
215+
# Endpoint to connect to
216+
endpoint: https://your.lease.service.com
217+
# **IMPORTANT** the job-status always has to be defined like this
218+
job_status: ${{ job.status }}
219+
# Optional: timeout_seconds (how long to wait before something is considered going wrong)
220+
# timeout_seconds: 7200
221+
# Optional: interval_seconds (the polling interval)
222+
# timeout_seconds: 15
223+
- name: sleep
224+
# Only perform github actions when this run acquired the lease
225+
if: ${{ steps.acquire_lease.outputs.result == 'acquired' }}
226+
run: |
227+
sleep 30
228+
# Note: there is no further action required, the lease will be released in a post hook of the `Aquire lease` action.
229+
```

0 commit comments

Comments
 (0)