Skip to content

Commit 54e0649

Browse files
authored
Adding mise.toml for versioning. (#1625)
1 parent 78077cd commit 54e0649

File tree

9 files changed

+40
-12
lines changed

9 files changed

+40
-12
lines changed

.github/workflows/test-provider-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Checkout Repo
3030
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3131
- name: Install golangci-lint
32-
uses: golangci/golangci-lint-action@55c2c1448f86e01eaae002a5a3a9624417608d84 # v6
32+
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8
3333
with:
3434
working-directory: provider-ci
3535
- name: Configure git

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ This repository has the following components:
2525

2626
The following tools are required for generating and deploying GitHub Actions workflows:
2727

28-
- [Make](https://www.gnu.org/software/make/)
29-
- [npm](https://www.npmjs.com/)
30-
- [golangci-lint](https://golangci-lint.run/)
31-
- [shellcheck](https://github.com/koalaman/shellcheck)
28+
* [Mise](https://mise.jdx.dev/)
29+
30+
Dependencies required are modeled on `mise.toml`. Run `mise install` and `mise
31+
settings experimental=true` (required for Go binaries such as `golangci-lint`
32+
and `pulumictl`) to fetch and install them. Finally, run `mise env` to check if
33+
env variables are being set correctly.
3234

3335
## Building
3436

mise.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[tools]
2+
3+
go = '1.21'
4+
golangci-lint = '2.2.2'
5+
node = 'latest'
6+
pulumi = 'latest'
7+
yarn = '1.22.22'
8+
dotnet = '8'
9+
shellcheck = '0.10.0'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package contract
2+
3+
import "fmt"
4+
5+
func IgnoreError(f func() error) {
6+
if err := f(); err != nil {
7+
fmt.Printf("Explicitly ignoring and discarding error: %v", err)
8+
}
9+
}

provider-ci/internal/pkg/generate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"text/template"
1313

1414
"github.com/Masterminds/sprig"
15+
"github.com/pulumi/ci-mgmt/provider-ci/internal/pkg/contract"
1516
"github.com/pulumi/ci-mgmt/provider-ci/internal/pkg/migrations"
1617
"gopkg.in/yaml.v3"
1718
)
@@ -293,7 +294,7 @@ func renderTemplateFile(tmpl *template.Template, outPath string, ctx templateCon
293294
if err != nil {
294295
return err
295296
}
296-
defer outFile.Close()
297+
defer contract.IgnoreError(outFile.Close)
297298

298299
_, err = io.Copy(outFile, &outData)
299300
if err != nil {

provider-ci/internal/pkg/migrations/fixupBridgeImports.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"os/exec"
88
"path/filepath"
99
"strings"
10+
11+
"github.com/pulumi/ci-mgmt/provider-ci/internal/pkg/contract"
1012
)
1113

1214
//go:embed fixupBridgeImports.patch
@@ -25,7 +27,7 @@ func (fixupBridgeImports) Migrate(templateName, outDir string) error {
2527
if err != nil {
2628
return fmt.Errorf("error writing patch file: %w", err)
2729
}
28-
defer cleanup()
30+
defer contract.IgnoreError(cleanup)
2931

3032
patchCmd := exec.Command("go", "run", "github.com/uber-go/[email protected]", "-p", path, "./provider/resources.go")
3133
patchCmd.Stdout = os.Stdout

provider-ci/internal/pkg/migrations/migrations.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"fmt"
55
"os"
66
"path/filepath"
7+
8+
"github.com/pulumi/ci-mgmt/provider-ci/internal/pkg/contract"
79
)
810

911
type Migration interface {
@@ -34,7 +36,7 @@ func Migrate(templateName, outDir string) error {
3436
}
3537

3638
// Returns the path to the temporary file and a function to clean it up, or an error.
37-
func writeTempFile(name, content string) (string, func(), error) {
39+
func writeTempFile(name, content string) (string, func() error, error) {
3840
dir, err := os.MkdirTemp(os.TempDir(), "pulumi-provider-ci-migration-files")
3941
if err != nil {
4042
return "", nil, err
@@ -44,7 +46,7 @@ func writeTempFile(name, content string) (string, func(), error) {
4446
if err != nil {
4547
return "", nil, err
4648
}
47-
defer f.Close()
49+
defer contract.IgnoreError(f.Close)
4850
_, err = f.WriteString(content)
49-
return path, func() { os.Remove(f.Name()) }, err
51+
return path, func() error { return os.Remove(f.Name()) }, err
5052
}

provider-ci/internal/pkg/migrations/removeExplicitSDKDependency.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"fmt"
66
"os"
77
"os/exec"
8+
9+
"github.com/pulumi/ci-mgmt/provider-ci/internal/pkg/contract"
810
)
911

1012
//go:embed removeExplicitSDKDependency.patch
@@ -23,7 +25,7 @@ func (removeExplicitSDKDependency) Migrate(templateName, outDir string) error {
2325
if err != nil {
2426
return fmt.Errorf("error writing patch file: %w", err)
2527
}
26-
defer cleanup()
28+
defer contract.IgnoreError(cleanup)
2729

2830
patchCmd := exec.Command("go", "run", "github.com/uber-go/[email protected]", "-p", path, "./provider/resources.go")
2931
patchCmd.Stdout = os.Stdout

provider-ci/internal/pkg/migrations/updateToDotnet8.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"regexp"
88

99
"github.com/bitfield/script"
10+
"github.com/pulumi/ci-mgmt/provider-ci/internal/pkg/contract"
1011
)
1112

1213
type updateToDotnet8 struct{}
@@ -44,7 +45,7 @@ func (updateToDotnet8) Migrate(templateName, outDir string) error {
4445
// This is useful for reading the content of a file and then writing back to that same file.
4546
func FileContent(path string) *script.Pipe {
4647
p := script.File(path)
47-
defer p.Close()
48+
defer contract.IgnoreError(p.Close)
4849
s, err := p.String()
4950
if err != nil {
5051
r := script.NewPipe()

0 commit comments

Comments
 (0)