Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ docs.kosli.com/content/client_reference/kosli*
docs.kosli.com/public/
docs.kosli.com/.netlify
*.tar.gz
/.idea
# keep it uncommented on main
docs.kosli.com/assets/metadata.json
tmp/
Expand Down
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ ensure_network:
ensure_gotestsum:
@go install gotest.tools/gotestsum@latest

clear_local_image_ref:
rm /tmp/server-image.txt

test_setup: ensure_gotestsum
# cat and exit if error
./hack/get-server-image.sh > /tmp/server-image.txt || (cat /tmp/server-image.txt && exit 1)
@test -f /tmp/server-image.txt || ./hack/get-server-image.sh /tmp/server-image.txt
export KOSLI_SERVER_IMAGE=$$(cat /tmp/server-image.txt) && ./bin/reset-or-start-server.sh

test_setup_restart_server: ensure_gotestsum
# cat and exit if error
./hack/get-server-image.sh > /tmp/server-image.txt || (cat /tmp/server-image.txt && exit 1)
@test -f /tmp/server-image.txt || ./hack/get-server-image.sh /tmp/server-image.txt
export KOSLI_SERVER_IMAGE=$$(cat /tmp/server-image.txt) && ./bin/reset-or-start-server.sh force

test_integration: deps vet ensure_network test_setup ## Run tests except the too slow ones
Expand Down
5 changes: 4 additions & 1 deletion cmd/kosli/attestJira.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ func (o *attestJiraOptions) run(args []string) error {
}

func (o *attestJiraOptions) validateJiraProjectKeys() error {
matchesJiraProjectKeys, err := regexp.Compile("^[A-Z][A-Z0-9]{1,9}$")
// According to Jira documentation https://confluence.atlassian.com/adminjiraserver/changing-the-project-key-format-938847081.html
// the Jira project key has to start with a capital letter and can then have capital letters numbers and underscore.
// But Jira itself will accept lower case letters when searching a repository for matching branches and commits
matchesJiraProjectKeys, err := regexp.Compile("^[A-Za-z][A-Za-z0-9_]{1,9}$")
if err != nil {
return err
}
Expand Down
19 changes: 16 additions & 3 deletions cmd/kosli/attestJira_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,28 @@ func (suite *AttestJiraCommandTestSuite) TestAttestJiraCmd() {
commitMessage: "EX-1 test commit",
},
},
{
name: "can specify lower case and underscore jira project key",
cmd: fmt.Sprintf(`attest jira --name bar
--jira-base-url https://kosli-test.atlassian.net --jira-username tore@kosli.com
--jira-project-key low
--jira-project-key A99
--jira-project-key A_99
--repo-root %s %s`, suite.tmpDir, suite.defaultKosliArguments),
golden: "jira attestation 'bar' is reported to trail: test-123\n",
additionalConfig: jiraTestsAdditionalConfig{
commitMessage: "low-1 test commit",
},
},
{
wantError: true,
name: "fails with an invalid Jira project key specified",
cmd: fmt.Sprintf(`attest jira --name bar
cmd: fmt.Sprintf(`attest jira --name bar
--jira-base-url https://kosli-test.atlassian.net --jira-username tore@kosli.com
--jira-project-key ex
--jira-project-key 1AB
--jira-project-key AB-44
--repo-root %s %s`, suite.tmpDir, suite.defaultKosliArguments),
golden: "Error: Invalid Jira project keys: ex, 1AB\n",
golden: "Error: Invalid Jira project keys: 1AB, AB-44\n",
additionalConfig: jiraTestsAdditionalConfig{
commitMessage: "EX-1 test commit",
},
Expand Down
9 changes: 8 additions & 1 deletion hack/get-server-image.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/bash
set -uo pipefail

if [ $# -lt 1 ]; then
echo "Output result file is missing" >&2
exit 1
fi

OUTPUT_FILE=$1; shift

# Check that jq is installed
if ! command -v jq &> /dev/null; then
echo "❌ Error: 'jq' is not installed. Please install it:" >&2
Expand Down Expand Up @@ -29,4 +36,4 @@ echo "$json" | jq -r '
| select(.name | test("merkely:"))
| select(.annotation.type != "exited")
| "\(.name | sub(":.*"; ""))@sha256:\(.fingerprint)"
'
' > ${OUTPUT_FILE}