Skip to content

Commit

Permalink
Merge pull request #62 from numtide/expose-cleanup-error
Browse files Browse the repository at this point in the history
  • Loading branch information
zimbatm authored Nov 18, 2024
2 parents 09dec2d + 51a5193 commit ccc5e1c
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.19' ]
go: [ '1.22' ]
steps:

- name: Set up Go ${{ matrix.go }}
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.51.2
version: v1.58.2
13 changes: 5 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ name: goreleaser
on:
push:
tags:
- 'v*'
- "v*"

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.19
-
name: Run GoReleaser
go-version: 1.22
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
Expand Down
24 changes: 17 additions & 7 deletions command/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func CmdCleanup(c *cli.Context) (err error) {
} else {
// undeploy all closed pull requests
var deployed []string

deployed, err = listDeployedPullRequests(listScript)
if err != nil {
return err
Expand All @@ -48,10 +49,13 @@ func CmdCleanup(c *cli.Context) (err error) {
if err != nil {
return err
}

openPRs := make([]string, len(prs))

for i, pr := range prs {
openPRs[i] = fmt.Sprintf("pr-%d", *pr.Number)
}

log.Println("open PRs:", openPRs)

// Now get a list of all the deployed PRs that are not open
Expand All @@ -64,9 +68,20 @@ func CmdCleanup(c *cli.Context) (err error) {

log.Println("to undeploy:", toUndeploy)

var lastErr error

for _, name := range toUndeploy {
log.Println("Undeploying", name)

pullRequestID, err := strconv.Atoi(name)
if err != nil {
log.Println("Unable to parse pull request id: ", name)

lastErr = err

continue
}

cmd := exec.Command(c.Args().Get(0), c.Args()[1:]...) //#nosec
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
Expand All @@ -75,20 +90,15 @@ func CmdCleanup(c *cli.Context) (err error) {
if err != nil {
log.Println("undeploy error: ", err)

continue
}

pullRequestID, err := strconv.Atoi(name)
if err != nil {
log.Println("Unable to parse pull request id: ", name)
lastErr = err

continue
}

destroyGitHubDeployments(ctx, ghCli, owner, repo, pullRequestID, ignoreMissing)
}

return nil
return lastErr
}

func contains(item string, list []string) bool {
Expand Down
7 changes: 0 additions & 7 deletions command/cleanup_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion command/please_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package command_test

import "testing"

func TestCmdPlease(t *testing.T) {
func TestCmdPlease(_ *testing.T) {
// Write your code here
}
30 changes: 24 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions gitsrc/gitsrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,34 +69,34 @@ func (x *gitSource) String(name string) (string, error) {

// These are implemented to satisfy the altsrc.InputSourceContext interface

func (x *gitSource) Int(name string) (int, error) {
func (x *gitSource) Int(_ string) (int, error) {
return 0, ErrNotSupported
}

func (x *gitSource) Duration(name string) (time.Duration, error) {
func (x *gitSource) Float64(_ string) (float64, error) {
return 0, ErrNotSupported
}

func (x *gitSource) Float64(name string) (float64, error) {
func (x *gitSource) Duration(_ string) (time.Duration, error) {
return 0, ErrNotSupported
}

func (x *gitSource) StringSlice(name string) ([]string, error) {
func (x *gitSource) StringSlice(_ string) ([]string, error) {
return nil, ErrNotSupported
}

func (x *gitSource) IntSlice(name string) ([]int, error) {
func (x *gitSource) IntSlice(_ string) ([]int, error) {
return nil, ErrNotSupported
}

func (x *gitSource) Generic(name string) (cli.Generic, error) { //nolint:nolintlint,ireturn
func (x *gitSource) Generic(_ string) (cli.Generic, error) { //nolint:nolintlint,ireturn
return nil, ErrNotSupported
}

func (x *gitSource) Bool(name string) (bool, error) {
func (x *gitSource) Bool(_ string) (bool, error) {
return false, ErrNotSupported
}

func (x *gitSource) BoolT(name string) (bool, error) {
func (x *gitSource) BoolT(_ string) (bool, error) {
return false, ErrNotSupported
}
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,5 @@ func main() {

if err := app.Run(os.Args); err != nil {
log.Fatal("ERROR:", err)
os.Exit(1)
}
}

0 comments on commit ccc5e1c

Please sign in to comment.