Skip to content

Commit

Permalink
Add actions var check
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiad200 committed Aug 9, 2021
1 parent bd86d5f commit 05405ba
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/nessie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ jobs:
TAG: ${{ needs.deploy-image.outputs.tag }}
# Setting Account_ID as a secret as a way to avoid specifying it here
REPO: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com
ACTIONS_VAR: "this_is_actions_var"
steps:
- name: Retrieve generated code
uses: actions/download-artifact@v2
Expand Down Expand Up @@ -446,6 +447,7 @@ jobs:
TAG: ${{ needs.deploy-image.outputs.tag }}
# Setting Account_ID as a secret as a way to avoid specifying it here
REPO: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com
ACTIONS_VAR: "this_is_actions_var"
steps:
- name: Retrieve generated code
uses: actions/download-artifact@v2
Expand Down Expand Up @@ -489,6 +491,7 @@ jobs:
TAG: ${{ needs.deploy-image.outputs.tag }}
# Setting Account_ID as a secret as a way to avoid specifying it here
REPO: ${{ secrets.AWS_ACCOUNT_ID }}.dkr.ecr.us-east-1.amazonaws.com
ACTIONS_VAR: "this_is_actions_var"
steps:
- name: Retrieve generated code
uses: actions/download-artifact@v2
Expand Down
5 changes: 5 additions & 0 deletions nessie/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ hooks:
description: Check webhooks for pre-commit works
properties:
url: "{{.URL}}/pre-commit"
query_params:
check_env_vars: {{ ENV.ACTIONS_VAR }}
`

const actionPostCommitYaml = `
Expand Down Expand Up @@ -119,6 +121,9 @@ func TestHooksSuccess(t *testing.T) {
require.Equal(t, commitRecord.Message, preCommitEvent.CommitMessage)
require.Equal(t, branch, preCommitEvent.SourceRef)
require.Equal(t, commitRecord.Metadata.AdditionalProperties, preCommitEvent.Metadata)
require.NotNil(t, webhookData.queryParams)
require.Contains(t, webhookData.queryParams, "check_env_vars")
require.Equal(t, webhookData.queryParams["check_env_vars"], []string{"this_is_actions_var"})

webhookData, err = responseWithTimeout(server, 1*time.Minute)
require.NoError(t, err)
Expand Down
10 changes: 6 additions & 4 deletions nessie/webhook_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import (
)

type hookResponse struct {
path string
err error
data []byte
path string
err error
data []byte
queryParams map[string][]string
}

type webhookServer struct {
Expand Down Expand Up @@ -95,7 +96,8 @@ func hookHandlerFunc(respCh chan hookResponse) func(http.ResponseWriter, *http.R
writer.WriteHeader(http.StatusInternalServerError)
return
}
respCh <- hookResponse{path: request.URL.Path, data: data}

respCh <- hookResponse{path: request.URL.Path, data: data, queryParams: request.URL.Query()}
_, _ = io.WriteString(writer, "OK")
writer.WriteHeader(http.StatusOK)
}
Expand Down

0 comments on commit 05405ba

Please sign in to comment.