Skip to content

Commit

Permalink
remove status check from rancher tag and shellcheck action (#502)
Browse files Browse the repository at this point in the history
* remove status check from rancher

* fix identation

* remove shellcheck
  • Loading branch information
tashima42 authored Nov 11, 2024
1 parent fa12d74 commit 2115055
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 49 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ on:
- master

jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
severity: info
scandir: 'bin/'
env:
SHELLCHECK_OPTS: -s sh -e SC1091 -e SC2034 -e SC2317
build:
name: Build
runs-on: ubuntu-latest
Expand All @@ -28,4 +16,3 @@ jobs:
make all
make test
10 changes: 2 additions & 8 deletions cmd/release/cmd/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ type tagRKE2CmdFlags struct {
RPMVersion *int
}

var (
tagRKE2Flags tagRKE2CmdFlags
tagRancherSkipStatusCheck bool
)
var tagRKE2Flags tagRKE2CmdFlags

// tagCmd represents the tag command.
var tagCmd = &cobra.Command{
Expand Down Expand Up @@ -178,7 +175,7 @@ var rancherTagSubCmd = &cobra.Command{
fmt.Println("dry run, skipping creating release")
return nil
}
releaseURL, err := rancher.CreateRelease(ctx, ghClient, &rancherRelease, opts, preRelease, tagRancherSkipStatusCheck, releaseType)
releaseURL, err := rancher.CreateRelease(ctx, ghClient, &rancherRelease, opts, preRelease, releaseType)
if err != nil {
return err
}
Expand Down Expand Up @@ -292,9 +289,6 @@ func init() {
tagRKE2Flags.ReleaseVersion = rke2TagSubCmd.Flags().StringP("release-version", "r", "r1", "Release version")
tagRKE2Flags.RCVersion = rke2TagSubCmd.Flags().String("rc", "", "RC version")
tagRKE2Flags.RPMVersion = rke2TagSubCmd.Flags().Int("rpm-version", 0, "RPM version")

// rancher
rancherTagSubCmd.Flags().BoolVarP(&tagRancherSkipStatusCheck, "skip-status-check", "s", false, "skip checking if CI is passing when creating a tag")
}

func releaseTypePreRelease(releaseType string) (bool, error) {
Expand Down
29 changes: 1 addition & 28 deletions release/rancher/rancher.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,25 +313,11 @@ func generatePrimeArtifactsHTML(content ArtifactsIndexContentGroup) ([]byte, err
}

// CreateRelease gets the latest commit in a release branch, checks if CI is passing and creates a github release, returning the created release HTML URL or an error
func CreateRelease(ctx context.Context, ghClient *github.Client, r *ecmConfig.RancherRelease, opts *repository.CreateReleaseOpts, preRelease, skipStatusCheck bool, releaseType string) (string, error) {
func CreateRelease(ctx context.Context, ghClient *github.Client, r *ecmConfig.RancherRelease, opts *repository.CreateReleaseOpts, preRelease bool, releaseType string) (string, error) {
if !semver.IsValid(opts.Tag) {
return "", errors.New("the tag isn't a valid semver: " + opts.Tag)
}

branch, _, err := ghClient.Repositories.GetBranch(ctx, r.RancherRepoOwner, rancherRepo, r.ReleaseBranch, true)
if err != nil {
return "", err
}
if branch.Commit.SHA == nil {
return "", errors.New("branch commit sha is nil")
}

if !skipStatusCheck {
if err := commitStateSuccess(ctx, ghClient, r.RancherRepoOwner, rancherRepo, *branch.Commit.SHA); err != nil {
return "", err
}
}

releaseName := opts.Tag
if preRelease {
latestVersionNumber := 1
Expand Down Expand Up @@ -363,19 +349,6 @@ func CreateRelease(ctx context.Context, ghClient *github.Client, r *ecmConfig.Ra
return createdRelease.GetHTMLURL(), err
}

func commitStateSuccess(ctx context.Context, ghClient *github.Client, owner, repo, commit string) error {
status, _, err := ghClient.Repositories.GetCombinedStatus(ctx, owner, repo, commit, &github.ListOptions{})
if err != nil {
return err
}

if *status.State != "success" {
return errors.New("expected commit " + commit + " to have state 'success', instead, got " + *status.State)
}

return nil
}

func CheckRancherRCDeps(ctx context.Context, org, gitRef string) (*RancherRCDeps, error) {
var content RancherRCDeps
files := []string{"Dockerfile.dapper", "go.mod", "/package/Dockerfile", "/pkg/apis/go.mod", "/pkg/settings/setting.go", "/scripts/package-env"}
Expand Down

0 comments on commit 2115055

Please sign in to comment.