Skip to content

Commit

Permalink
Merge branch 'main' into feature/github-actions-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
shawju authored Oct 14, 2021
2 parents 4fff9e1 + 8ac1bf7 commit 4edd9d1
Show file tree
Hide file tree
Showing 37 changed files with 426 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ tasks:
cmds:
- docker run --rm -v $(pwd):/workdir -w /workdir {{.FULLY_QUALIFIED_IMAGE_NAME}}:{{.TAG}} shellspec

updates:
desc: Run automated check for updates
vars:
TAG: '{{ coalesce .TAG "<no value>" }}'
preconditions:
- sh: test "{{.TAG}}" != "<no value>"
msg: Required variable 'TAG' not set
cmds:
- docker run --rm -v $(pwd):/workdir -w /workdir {{.FULLY_QUALIFIED_IMAGE_NAME}}:{{.TAG}} shellspec updates

codefresh:test:
cmds:
- shellspec
Expand Down
69 changes: 69 additions & 0 deletions lib_updates
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env shellspec

# Check DNF for an update to the given package
# Inputs: package to check for an update, e.g. "container.io"
# Return: 0 if an update is availabe; non-0 if no update is available
checkForDnfUpdate() {
dnf list updates 2>&1 | grep "^$*" > /dev/null
}

# Gets latest release from DNF
# Inputs: package to check for an update, e.g. "skopeo.x86_64"
# Return: String containing the latest release version, e.g. "0.1.2"
getLatestVersionFromDnf() {
dnf list updates 2> /dev/null | grep "$*" 2> /dev/null | awk '{print $2}' 2> /dev/null
}

# Get the latest release from a GitHub project
# Inputs: owner and repo of the GitHub project to check, e.g. "docker/compose"
# Output: String containing the latest release version, e.g. "0.1.2"
getLatestGitHubRelease() {
curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/"$*"/releases" 2> /dev/null | \
jq '.[0].name' 2> /dev/null
}

# Get the latest tag from a GitHub project
# Inputs: owner and repo of the GitHub project to check, e.g. "docker/compose"
# Output: String containing the latest tag version, e.g. "0.1.2"
getLatestGitHubTag() {
curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/"$*"/tags" 2> /dev/null | \
jq '.[0].name' 2> /dev/null
}

# Check pip for an update to the given package
# Inputs: package to check for an update, e.g. "awscli"
# Return: 0 if an update is availabe; non-0 if no update is available
checkForPipUpdate() {
pip list --outdated 2> /dev/null | grep "^$*" > /dev/null
}

# Get latest version of an update from Pip
# Inputs: package to check for an update, e.g. "pipenv"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromPip() {
pip list --outdated 2> /dev/null | grep "$*" 2> /dev/null | awk '{print $3}' 2> /dev/null
}

# Get the latest version from asdf
# Input: name of the package, e.g. "terraform"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromAsdf() {
asdf latest $* 2> /dev/null
}

# Get the latest version from asdf list
# Some packages are not supported with asdf latest
# Input: name of the package, e.g. "java"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromAsdfList() {
asdf list $* 2> /dev/null
}

# Get the latest version from npm
# Inputs: name of the package, e.g. "serverless"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromNpm() {
npm show $* version 2> /dev/null
}
10 changes: 10 additions & 0 deletions updates/asdf_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for an asdf update"
Include ./lib_updates
It "validates asdf is up-to-date via GitHub"
When call getLatestGitHubTag asdf-vm/asdf
The output should include "${ASDF_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/aws_cli_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a AWS CLI update"
Include ./lib_updates
It "validates AWS CLI is up-to-date via pip"
When call getLatestVersionFromPip awscli
The output should include "${AWS_CLI_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/chart_releaser_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Helm Chart Releaser update"
Include ./lib_updates
It "validates Helm Chart Releaser is up-to-date via asdf"
When call getLatestVersionFromAsdf helm-cr
The output should include "${CHART_RELEASER_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/docker_compose_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Docker Compose update"
Include ./lib_updates
It "validates Docker Compose is up-to-date via GitHub"
When call getLatestGitHubTag docker/compose
The output should include "${DOCKER_COMPOSE_VERSION}"
The status should eq 0
End
End
9 changes: 9 additions & 0 deletions updates/docker_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env shellspec

Describe "Check for a Docker update"
Include ./lib_updates
It "checks DNF update list for Docker"
When call checkForDnfUpdate docker-ce.x86_64
The status should not eq 0
End
End
10 changes: 10 additions & 0 deletions updates/fossa_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Fossa update"
Include ./lib_updates
It "validates Fossa is up-to-date via GitHub"
When call getLatestGitHubRelease fossas/fossa-cli
The output should include "${FOSSA_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/go_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Go update"
Include ./lib_updates
It "validates Go is up-to-date via asdf"
When call getLatestVersionFromAsdf golang
The output should include "${GO_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/go_task_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Go-Task update"
Include ./lib_updates
It "validates Go-Task is up-to-date via GitHub"
When call getLatestGitHubTag go-task/task
The output should include "${GO_TASK_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/golangci_lint_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for GolangCI Lint update"
Include ./lib_updates
It "validates GolangCI Lint is up-to-date via asdf"
When call getLatestVersionFromAsdf golangci-lint
The output should include "${GOLANGCI_LINT_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/gomplate_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Gomplate update"
Include ./lib_updates
It "validates Gomplate is up-to-date via GitHub"
When call getLatestGitHubTag hairyhenderson/gomplate
The output should include "${GOMPLATE_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/goreleaser_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Go Releaser update"
Include ./lib_updates
It "validates Go Releaser is up-to-date via asdf"
When call getLatestVersionFromAsdf goreleaser
The output should include "${GORELEASER_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/hadolint_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Hadolint update"
Include ./lib_updates
It "validates Hadolint is up-to-date via GitHub"
When call getLatestGitHubTag hadolint/hadolint
The output should include "${HADOLINT_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/helm_diff_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Helm Diff update"
Include ./lib_updates
It "validates Helm Diff is up-to-date via GitHub"
When call getLatestGitHubTag databus23/helm-diff
The output should include "${HELM_DIFF_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/helm_git_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Helm Git update"
Include ./lib_updates
It "validates Helm Git is up-to-date via GitHub"
When call getLatestGitHubTag aslafy-z/helm-git
The output should include "${HELM_GIT_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/helm_s3_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Helm S3 update"
Include ./lib_updates
It "validates Helm S3 is up-to-date via GitHub"
When call getLatestGitHubTag hypnoglow/helm-s3
The output should include "${HELM_S3_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/helm_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Helm update"
Include ./lib_updates
It "validates Helm is up-to-date via asdf"
When call getLatestVersionFromAsdf helm
The output should include "${HELM_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/helmfile_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Helmfile update"
Include ./lib_updates
It "validates Helmfile is up-to-date via asdf"
When call getLatestVersionFromAsdf helmfile
The output should include "${HELMFILE_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/java_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Java update"
Include ./lib_updates
It "validates Java is up-to-date via asdf"
When call getLatestVersionFromAsdfList java
The output should include "${JAVA_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/klar_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Klar update"
Include ./lib_updates
It "validates Klar is up-to-date via GitHub"
When call getLatestGitHubRelease optiopay/klar
The output should include "${KLAR_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/kubectl_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Kubectl update"
Include ./lib_updates
It "validates Kubectl is up-to-date via asdf"
When call getLatestVersionFromAsdf kubectl
The output should include "${KUBECTL_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/maven_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Maven update"
Include ./lib_updates
It "validates Maven is up-to-date via asdf"
When call getLatestVersionFromAsdf maven
The output should include "${MAVEN_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/nodejs_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Node update"
Include ./lib_updates
It "validates Node is up-to-date via asdf"
When call getLatestVersionFromAsdf nodejs
The output should include "${NODEJS_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/pipenv_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Pipenv update"
Include ./lib_updates
It "validates Pipenv is up-to-date via pip"
When call getLatestVersionFromPip pipenv
The output should include "${PIPENV_VERSION}"
The status should eq 0
End
End
9 changes: 9 additions & 0 deletions updates/podman_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env shellspec

Describe "Check for Podman update"
Include ./lib_updates
It "gets the latest version of Podman"
When call checkForDnfUpdate podman.x86_64
The status should not eq 0
End
End
10 changes: 10 additions & 0 deletions updates/pre_commit_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Pre-commit update"
Include ./lib_updates
It "validates Pre-commit is up-to-date via pip"
When call getLatestVersionFromPip pre-commit
The output should include "${PRE_COMMIT_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/python_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Python update"
Include ./lib_updates
It "validates Python is up-to-date via asdf"
When call getLatestVersionFromAsdf python
The output should include "${PYTHON_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/serverless_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for Serverless update"
Include ./lib_updates
It "validates Serverless is up-to-date via npm"
When call getLatestVersionFromNpm serverless
The output should include "${SERVERLESS_VERSION}"
The status should eq 0
End
End
10 changes: 10 additions & 0 deletions updates/shellcheck_spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env shellspec

Describe "Check for a Shellcheck update"
Include ./lib_updates
It "validates Shellcheck is up-to-date via GitHub"
When call getLatestGitHubTag koalaman/shellcheck
The output should include "${SHELLCHECK_VERSION}"
The status should eq 0
End
End
Loading

0 comments on commit 4edd9d1

Please sign in to comment.