Skip to content

Commit

Permalink
Add github build and release workflows; Fix status logging when polling
Browse files Browse the repository at this point in the history
  • Loading branch information
gregfurman committed Apr 27, 2024
1 parent e85de89 commit fae783d
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Go package

on: [push]

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.21'


build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: Lint
uses: golangci/golangci-lint-action@v5
with:
version: v1.57

- name: Install Dependencies
run: go get .

- name: Test
run: go test -v ./...

- name: Build
run: go build -o service main.go
76 changes: 76 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: tag-release

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
tag:
if: ${{ github.repository == 'gregfurman/pipescope' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: /usr/bin/git config --global user.email [email protected]
- run: /usr/bin/git config --global user.name 'GitHub Actions Release Tagger'
- run: hack/tag-release.sh
id: tag_release
outputs:
release_tag: ${{ steps.tag_release.outputs.release_tag }}

release:
needs: tag
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3

- name: Get previous tag
id: prev_tag
run: echo "::set-output name=PREV_TAG::$(git describe --abbrev=0 --tags $(git rev-list --tags --skip=1 --max-count=1))"

- name: Get commit log
id: commit_log
run: echo "::set-output name=COMMIT_LOG::$(git log --pretty=format:'- %s (%h)' ${PREV_TAG}..HEAD)"

- name: Setup Golang
uses: actions/setup-go@v2
with:
go-version: 1.21.x

- name: Build Go Binary
run: |
GOOS=linux GOARCH=amd64 go build -o pipescope main.go
- uses: actions/upload-artifact@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ecr-credential-provider
path: ecr-credential-provider

- uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.tag.outputs.release_tag }}
release_name: ${{ needs.tag.outputs.release_tag }}
body: |
Changes in this release:
${{ steps.commit_log.outputs.COMMIT_LOG }}
draft: false
prerelease: false

- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pipescope
asset_name: pipescope
asset_content_type: application/octet-stream
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func run(svc *checker.Service, pollFrequency time.Duration) error {
if err != nil {
return fmt.Errorf("checker Service GET pipeline failed: %w", err)
}

status := pipeline.Status

slog.Group("pipeline")
Expand All @@ -80,9 +81,10 @@ func run(svc *checker.Service, pollFrequency time.Duration) error {
)

logger.Info(fmt.Sprintf("Polled Pipeline [status=%s]", pipeline.Status))

statusCh, _ := svc.PollPipelineStatus(pipeline.ProjectID, pipeline.ID, pollFrequency)
for s := range statusCh {
if status == "" {
if s == "" {
continue
}

Expand Down

0 comments on commit fae783d

Please sign in to comment.