Skip to content

Commit

Permalink
Merge branch 'master' into STEP-2064-simplified-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tothszabi committed Jan 21, 2025
2 parents 165a667 + f80737a commit c3bffab
Show file tree
Hide file tree
Showing 184 changed files with 8,070 additions and 1,645 deletions.
6 changes: 4 additions & 2 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
version: 2

before:
hooks:
- go mod tidy
Expand Down Expand Up @@ -38,14 +40,14 @@ archives:
blobs:
- provider: gs
bucket: bitrise-cli-releases-prod
folder: /{{ .Tag }}
directory: /{{ .Tag }}
ids:
- default
- provider: s3
bucket: bitrise-cli-releases-prod
region: us-east-1
endpoint: "{{ .Env.AWS_ENDPOINT_URL }}"
folder: /
directory: /
ids:
- s3

Expand Down
12 changes: 3 additions & 9 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ step_bundles:
#!/usr/bin/env bash
set -ex
goreleaser release --snapshot --rm-dist
goreleaser release --snapshot --clean
- deploy-to-bitrise-io@2: { }

setup_repo:
Expand Down Expand Up @@ -362,14 +362,8 @@ step_bundles:
- content: |-
#!/bin/bash
set -ex
if [ "$(uname)" = "Linux" ]; then
wget -O /tmp/goreleaser.deb https://github.com/goreleaser/goreleaser/releases/download/v1.19.2/goreleaser_1.19.2_amd64.deb
sudo dpkg -i /tmp/goreleaser.deb
else
go install github.com/goreleaser/goreleaser@latest
asdf reshim golang
fi
go install github.com/goreleaser/goreleaser/v2@latest
asdf reshim golang
meta:
bitrise.io:
Expand Down
196 changes: 196 additions & 0 deletions bitrise/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,199 @@ workflows:
require.Error(t, err)
require.Equal(t, 0, len(warnings))
}

func TestConfigModelFromYAMLFileContent_StepListValidation(t *testing.T) {
tests := []struct {
name string
config string
wantErr string
}{
{
name: "Invalid bitrise.yml: step bundle in a step bundle's steps list",
config: `
format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
step_bundles:
build: {}
test:
steps:
- bundle::build: {}`,
wantErr: "step bundle (test) has config issue: step bundle is not allowed in a step bundle's step list",
},
{
name: "Invalid bitrise.yml: with group in a step bundle's steps list",
config: `
format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
step_bundles:
test:
steps:
- with: {}`,
wantErr: "step bundle (test) has config issue: 'with' group is not allowed in a step bundle's step list",
},
{
name: "Invalid bitrise.yml: step bundle in a 'with' group's steps list",
config: `
format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
services:
postgres:
image: postgres:13
workflows:
primary:
steps:
- with:
services:
- postgres
steps:
- bundle::test: {}`,
wantErr: "invalid 'with' group in workflow (primary): step bundle is not allowed in a 'with' group's step list",
},
{
name: "Invalid bitrise.yml: with group in a 'with' group's steps list",
config: `
format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
services:
postgres:
image: postgres:13
workflows:
primary:
steps:
- with:
services:
- postgres
steps:
- with: {}`,
wantErr: "invalid 'with' group in workflow (primary): 'with' group is not allowed in a 'with' group's step list",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, warns, err := ConfigModelFromFileContent([]byte(tt.config), false)
require.Equal(t, []string(nil), warns)
if tt.wantErr != "" {
require.EqualError(t, err, tt.wantErr)
} else {
require.NoError(t, err)
}
})
}
}

func TestConfigModelFromJSONFileContent_StepListValidation(t *testing.T) {
tests := []struct {
name string
config string
wantErr string
}{
{
name: "Invalid bitrise.yml: step bundle in a step bundle's steps list",
config: `{
"format_version": "11",
"default_step_lib_source": "https://github.com/bitrise-io/bitrise-steplib.git",
"step_bundles": {
"build": {},
"test": {
"steps": [
{
"bundle::build": {}
}
]
}
}
}`,
wantErr: "step bundle (test) has config issue: step bundle is not allowed in a step bundle's step list",
},
{
name: "Invalid bitrise.yml: with group in a step bundle's steps list",
config: `{
"format_version": "11",
"default_step_lib_source": "https://github.com/bitrise-io/bitrise-steplib.git",
"step_bundles": {
"test": {
"steps": [
{
"with": {}
}
]
}
}
}`,
wantErr: "step bundle (test) has config issue: 'with' group is not allowed in a step bundle's step list",
},
{
name: "Invalid bitrise.yml: step bundle in a 'with' group's steps list",
config: `{
"format_version": "11",
"default_step_lib_source": "https://github.com/bitrise-io/bitrise-steplib.git",
"services": {
"postgres": {
"image": "postgres:13"
}
},
"workflows": {
"primary": {
"steps": [
{
"with": {
"services": [
"postgres"
],
"steps": [
{
"bundle::test": {}
}
]
}
}
]
}
}
}`,
wantErr: "invalid 'with' group in workflow (primary): step bundle is not allowed in a 'with' group's step list",
},
{
name: "Invalid bitrise.yml: with group in a 'with' group's steps list",
config: `{
"format_version": "11",
"default_step_lib_source": "https://github.com/bitrise-io/bitrise-steplib.git",
"services": {
"postgres": {
"image": "postgres:13"
}
},
"workflows": {
"primary": {
"steps": [
{
"with": {
"services": [
"postgres"
],
"steps": [
{
"with": {}
}
]
}
}
]
}
}
}`,
wantErr: "invalid 'with' group in workflow (primary): 'with' group is not allowed in a 'with' group's step list",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, warns, err := ConfigModelFromFileContent([]byte(tt.config), true)
require.Equal(t, []string(nil), warns)
if tt.wantErr != "" {
require.EqualError(t, err, tt.wantErr)
} else {
require.NoError(t, err)
}
})
}
}
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ require (
github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.22
github.com/bitrise-io/goinp v0.0.0-20240103152431-054ed78518ef
github.com/bitrise-io/stepman v0.0.0-20240828074035-6ae1a5f5efde
github.com/go-git/go-git/v5 v5.12.0
github.com/go-git/go-git/v5 v5.13.0
github.com/gofrs/uuid v4.3.1+incompatible
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/hashicorp/go-version v1.4.0
github.com/heimdalr/dag v1.4.0
github.com/ryanuber/go-glob v1.0.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/urfave/cli v1.22.15
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0
golang.org/x/sys v0.25.0
golang.org/x/sys v0.28.0
gopkg.in/yaml.v2 v2.4.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v1.0.0 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-git/go-billy/v5 v5.6.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand All @@ -50,13 +50,13 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/tools v0.25.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit c3bffab

Please sign in to comment.