Skip to content

Commit

Permalink
1. tiltfile clean up
Browse files Browse the repository at this point in the history
2. stop using .env, use .secret
3. update doc
  • Loading branch information
Greyeye committed Jul 1, 2024
1 parent a9daf1c commit a0ca1ae
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
- synchronize

env:
FS_TAG: 0.0.0-pr${{ github.event.pull_request.number }}
FS_TAG: 0.0.0-pr${{ github.event.pull_request.number }}-${{ github.job }}

jobs:
build:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,5 @@ localdev/terraform/gitlab/project.url
*.DS_Store
/kubechecks
localdev/terraform/github/project.url
.secret
.arg
1 change: 0 additions & 1 deletion .env.example → .secret.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
GITLAB_TOKEN=xyz
KUBECHECKS_LOG_LEVEL=debug
OPENAI_API_TOKEN=xyz
GITHUB_TOKEN=xyz
KUBECHECKS_WEBHOOK_SECRET=xyz
17 changes: 11 additions & 6 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ test_go(
],
)


# get the git commit ref
def get_git_head():
result = local('git rev-parse --short HEAD')
return result

# read .tool-versions file and return a dictionary of tools and their versions
def parse_tool_versions(fn):
if not os.path.exists(fn):
Expand All @@ -160,16 +166,11 @@ def parse_tool_versions(fn):
continue
parts = line.split(' ', 1)
tools[parts[0].strip()] = parts[1].strip()
tools['githead'] = str(local('git rev-parse --short HEAD'))
tools['githead'] = str(get_git_head())
return tools

tool_versions = parse_tool_versions(".tool-versions")

# get the git commit ref
def get_git_head():
result = local('git rev-parse --short HEAD')
return result

earthly_build(
context='.',
target="+docker-debug",
Expand All @@ -185,6 +186,10 @@ earthly_build(
'--KUSTOMIZE_VERSION='+tool_versions.get('kustomize'),
'--STATICCHECK_VERSION='+tool_versions.get('staticcheck'),
'--GIT_COMMIT='+tool_versions.get('githead'),
'--GITLAB_TOKEN='+os.getenv('GITLAB_TOKEN') if 'gitlab' in cfg.get('vcs-type', 'gitlab') else os.getenv('GITHUB_TOKEN'),
'--KUBECHECKS_LOG_LEVEL='+os.getenv('KUBECHECKS_LOG_LEVEL'),
'--OPENAI_API_TOKEN='+os.getenv('OPENAI_API_TOKEN'),
'--KUBECHECKS_WEBHOOK_SECRET='+os.getenv('KUBECHECKS_WEBHOOK_SECRET'),
],
)

Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ If you're using minikube with Tilt we recommend following this [guide](https://g

### Code Changes

We use Earthly to simplify our CI/CD process with `kubechecks`. There's a thin wrapper around earthly that passes some common arguments in the root of the repo called `./earthly.sh` that should be used instead of calling earthly directly. This also simplifies testing changes locally before pushing them up to ensure your PR will pass all required checks. The best command to run is `./earthly.sh +test` this will pull all the required dependencies (including any new ones that you have added). It will then run [go vet](https://pkg.go.dev/cmd/vet), and if those pass it will run `go test` with race detection enabled. You can also always run these commands directly `go test -race ./...` will run all tests in the repo with race detection enabled. Please ensure that `./earthly +test` is passing before opening a PR.
We use Earthly to simplify our CI/CD process with `kubechecks`. There's a thin wrapper around earthly that passes some common arguments in the root of the repo called `./earthly.sh` that should be used instead of calling earthly directly. This also simplifies testing changes locally before pushing them up to ensure your PR will pass all required checks. The best command to run is `./earthly.sh +test` this will pull all the required dependencies (including any new ones that you have added). It will then run [go vet](https://pkg.go.dev/cmd/vet), and if those pass it will run `go test` with race detection enabled. You can also always run these commands directly `go test -race ./...` will run all tests in the repo with race detection enabled. Please ensure that `./earthly.sh +test` is passing before opening a PR.

### Documentation Changes

Expand Down
3 changes: 2 additions & 1 deletion earthly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ earthly $* \
--KUBECONFORM_VERSION=${kubeconform_tool_version} \
--KUSTOMIZE_VERSION=${kustomize_tool_version} \
--STATICCHECK_VERSION=${staticcheck_tool_version} \
--GIT_COMMIT=$(git rev-parse --short HEAD)
--GIT_COMMIT=$(git rev-parse --short HEAD) \
--KUBECHECKS_LOG_LEVEL=debug
2 changes: 1 addition & 1 deletion pkg/vcs/github_client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func (c *Client) CreateHook(ctx context.Context, ownerAndRepoName, webhookUrl, w
Name: pkg.Pointer("web"),
})
if err != nil || resp.StatusCode != 200 {
return errors.Wrap(err, "failed to create hook")
return errors.Wrap(err, fmt.Sprintf("failed to create hook, statuscode: %d", resp.StatusCode))
}

return nil
Expand Down

0 comments on commit a0ca1ae

Please sign in to comment.