-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Workflows to provide integration tests
Add a GitHub Workflow to provide integration tests against the code and documents in this repository, where possible. Also add the relevant configuration to install and set up the tooling to run these checks.
- Loading branch information
1 parent
4b24e9c
commit 08ca4a3
Showing
12 changed files
with
891 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: daily | ||
commit-message: | ||
prefix: actions | ||
include: scope | ||
labels: | ||
- type/dependencies | ||
- update/github-workflows | ||
- release/chore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
name: Checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
defaults: | ||
run: | ||
# Error handling and pipefile must be explicitly set via the default shell | ||
# https://github.com/actions/runner/issues/353#issuecomment-1067227665 | ||
shell: bash --noprofile --norc -eo pipefail {0} | ||
|
||
jobs: | ||
linting: | ||
name: Lint .github Repository | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
|
||
# Prepare the local environment with the expected tooling from Go, Python, | ||
# and Node languages, as well as local installs via apt on Ubuntu. | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version-file: tools/go.mod | ||
cache-dependency-path: tools/go.sum | ||
cache: true | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.12 | ||
cache: pip | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: tools/package.json | ||
cache-dependency-path: tools/yarn.lock | ||
cache: yarn | ||
|
||
- name: Install required Go tools | ||
run: scripts/bin/install-go-tools | ||
|
||
- name: Install required Python tools | ||
run: scripts/bin/install-python-tools | ||
|
||
- name: Install required Node tools | ||
run: scripts/bin/install-node-tools | ||
|
||
- name: Lint the workflows-terraform repository | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
task clean lint \ | ||
--output group \ | ||
--output-group-begin '::group::{{ .TASK }}' \ | ||
--output-group-end '::endgroup::' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
# vim:set ft=bash: | ||
|
||
LIB_DIR="$(dirname "${0}")/../lib/" | ||
# shellcheck source=../lib/common.sh | ||
source "${LIB_DIR}/common.sh" | ||
|
||
# Usage: ::command:: | ||
# | ||
# Script to automate the installation of standard tooling which should be | ||
# available within the GitHub Workflows. This uses the classic Go Module for | ||
# managing tooling, while also enabling Dependabot to review and update versions | ||
# as required on updates and security issues. | ||
# | ||
# Environment variables: | ||
# | ||
# GITHUB_WORKSPACE - Required from Workflows, and sets the current location of | ||
# the root of the checked out GitHub repository for which | ||
# this GitHub Workflow is being run. | ||
# | ||
# Returns 0 if all tools successfully installed | ||
# Returns 1 if any step fails | ||
|
||
check_variables GITHUB_REPOSITORY GITHUB_WORKSPACE | ||
check_commands go | ||
|
||
TOOLS_DIR="${GITHUB_WORKSPACE}/tools" | ||
show_debug "TOOLS_DIR = '${TOOLS_DIR}'" | ||
|
||
cd "${TOOLS_DIR}" \ | ||
|| exit_error "TOOLS_DIR does not exist" "Could not enter ${TOOLS_DIR}" | ||
|
||
# Ensure that all the required libraries are downloaded based on what has been | ||
# configured in go.mod and go.sum | ||
start_group "go mod download" | ||
go mod download | ||
end_group | ||
|
||
# Iterate through each of the entries provided in tools.go and install the | ||
# applications into the local environment so they can be installed | ||
grep _ tools.go \ | ||
| awk -F'"' '{print $2}' \ | ||
| while read -r tool; do | ||
start_group "${tool}" | ||
go install "${tool}" | ||
end_group | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
# vim:set ft=bash: | ||
|
||
LIB_DIR="$(dirname "${0}")/../lib/" | ||
# shellcheck source=../lib/common.sh | ||
source "${LIB_DIR}/common.sh" | ||
|
||
# Usage: ::command:: | ||
# | ||
# Script to automate the installation of standard tooling which should be | ||
# available within the GitHub Workflows. This uses package.json for NPM to | ||
# manage the tooling, while also enabling Dependabot to review and update | ||
# versions as required on updates and security issues. | ||
# | ||
# Environment variables: | ||
# | ||
# GITHUB_WORKSPACE - Required from Workflows, and sets the current location of | ||
# the root of the checked out GitHub repository for which | ||
# this GitHub Workflow is being run. | ||
# | ||
# Returns 0 if all tools successfully installed | ||
# Returns 1 if any step fails | ||
|
||
check_variables GITHUB_REPOSITORY GITHUB_WORKSPACE | ||
check_commands pip | ||
|
||
TOOLS_DIR="${GITHUB_WORKSPACE}/tools" | ||
show_debug "TOOLS_DIR = '${TOOLS_DIR}'" | ||
|
||
cd "${TOOLS_DIR}" \ | ||
|| exit_error "TOOLS_DIR does not exist" "Could not enter ${TOOLS_DIR}" | ||
|
||
# Ensure that all the required libraries are downloaded based on what has been | ||
# configured in go.mod and go.sum | ||
start_group "npm install" | ||
yarn install | ||
add_path "${TOOLS_DIR}/node_modules/.bin" | ||
end_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env bash | ||
# vim:set ft=bash: | ||
|
||
LIB_DIR="$(dirname "${0}")/../lib/" | ||
# shellcheck source=../lib/common.sh | ||
source "${LIB_DIR}/common.sh" | ||
|
||
# Usage: ::command:: | ||
# | ||
# Script to automate the installation of standard tooling which should be | ||
# available within the GitHub Workflows. This uses requirements.txt for PIP to | ||
# manage the tooling, while also enabling Dependabot to review and update | ||
# versions as required on updates and security issues. | ||
# | ||
# Environment variables: | ||
# | ||
# GITHUB_WORKSPACE - Required from Workflows, and sets the current location of | ||
# the root of the checked out GitHub repository for which | ||
# this GitHub Workflow is being run. | ||
# | ||
# Returns 0 if all tools successfully installed | ||
# Returns 1 if any step fails | ||
|
||
check_variables GITHUB_REPOSITORY GITHUB_WORKSPACE | ||
check_commands pip | ||
|
||
TOOLS_DIR="${GITHUB_WORKSPACE}/tools" | ||
show_debug "TOOLS_DIR = '${TOOLS_DIR}'" | ||
|
||
cd "${TOOLS_DIR}" \ | ||
|| exit_error "TOOLS_DIR does not exist" "Could not enter ${TOOLS_DIR}" | ||
|
||
# Ensure that all the required libraries are downloaded based on what has been | ||
# configured in go.mod and go.sum | ||
start_group "pip install -r requirements.txt" | ||
pip install -r requirements.txt | ||
end_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Bind variables from the environment before use | ||
CI=${CI:-false} | ||
DEBUG=${DEBUG:-} | ||
|
||
# Set up colours for improving output | ||
DIM='\033[2m' | ||
RED='\033[0;31m' | ||
YELLOW='\033[0;33m' | ||
WHITE='\033[0;37m' | ||
BLUE='\033[0;34m' | ||
NC='\033[0m' # No Color | ||
|
||
# Check to see if the variable name provided both exists and has a value | ||
# associated with it, otherwise error and exit the script | ||
function check_variables { | ||
for variable in "${@}"; do | ||
check_variable "${variable}" | ||
done | ||
} | ||
# Check to see if the variable name provided both exists and has a value | ||
# associated with it, otherwise error and exit the script | ||
function check_variable { | ||
set +u # Don't error out on unbound variables in this function | ||
if [[ -z "${!1}" ]]; then | ||
exit_error "Missing the environment variable '${1}'" | ||
fi | ||
set -u | ||
show_debug "\$${1} = '${!1}'" | ||
} | ||
|
||
# Check to see if all the commands provided exists and are executable, otherwise | ||
# error and exit the script | ||
function check_commands { | ||
for command in "${@}"; do | ||
check_command "${command}" | ||
done | ||
} | ||
|
||
# Check to see if the command provided both exists and is executable, otherwise | ||
# error and exit the script | ||
function check_command { | ||
if [[ ! -x "$(command -v "${1}")" ]]; then | ||
exit_error "Missing the ${1} application. Please install and try again." | ||
fi | ||
show_debug "${1} = '$(command -v "${1}")'" | ||
} | ||
|
||
# Initiate the starting of a grouped output for GitHub Actions | ||
function start_group { | ||
if [[ "${CI}" == "true" ]]; then | ||
echo >&2 "::group::${1}" | ||
fi | ||
show_stage "${1}" | ||
} | ||
|
||
# End the grouped output section for GitHub Actions | ||
function end_group { | ||
if [[ "${CI}" == "true" ]]; then | ||
echo >&2 "::endgroup::" | ||
fi | ||
} | ||
|
||
# Output a debug message for GitHub Actions | ||
function show_debug { | ||
if [[ "${CI}" == "true" ]]; then | ||
echo >&2 "::debug::${*}" | ||
elif [[ -n "${DEBUG}" ]]; then | ||
echo >&2 -e "${DIM}DEBUG: ${*}${NC}" | ||
fi | ||
} | ||
|
||
# Output the header for a new stage in the application | ||
function show_stage { | ||
echo -e "${YELLOW}==>${NC} ${WHITE}${1}${NC}" | ||
} | ||
|
||
# Output the message for a step in the application | ||
function show_step { | ||
echo -e " ${BLUE}->${NC} ${WHITE}${1}${NC}" | ||
} | ||
|
||
# Append a directory to PATH for GitHub Workflows | ||
function add_path { | ||
show_debug "\$PATH += \"${1}\" >> ${GITHUB_PATH:-/dev/null}" | ||
echo "${1}" >>"${GITHUB_PATH:-/dev/null}" | ||
} | ||
|
||
# Define an output in the GitHub Action for GitHub Workflows | ||
function put_output { | ||
show_debug "${1}=\"${2}\" >> ${GITHUB_OUTPUT:-/dev/null}" | ||
echo "${1}=\"${2}\"" >>"${GITHUB_OUTPUT:-/dev/null}" | ||
} | ||
|
||
# Output an error message for GitHub Actions | ||
function show_error { | ||
local title=${1} | ||
shift | ||
|
||
if [[ "${CI}" == "true" ]]; then | ||
echo >&2 "::error title=${title}::${*}" | ||
else | ||
echo >&2 -e "${RED}ERROR${NC}: ${RED}${title}{$NC} (${*})" | ||
fi | ||
} | ||
|
||
# Output an error message for GitHub Actions and then immediately exit the | ||
# script | ||
function exit_error { | ||
show_error "${*}" | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
module github.com/msicie/avigilon-alta-video_workflows-terraform/tools | ||
|
||
go 1.21 | ||
|
||
require ( | ||
github.com/go-task/task/v3 v3.35.1 | ||
github.com/minamijoyo/hcledit v0.2.10 | ||
) | ||
|
||
require ( | ||
github.com/Masterminds/semver/v3 v3.2.1 // indirect | ||
github.com/agext/levenshtein v1.2.1 // indirect | ||
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect | ||
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/fatih/color v1.16.0 // indirect | ||
github.com/fsnotify/fsnotify v1.4.7 // indirect | ||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/hashicorp/hcl/v2 v2.18.0 // indirect | ||
github.com/hashicorp/logutils v1.0.0 // indirect | ||
github.com/inconshreveable/mousetrap v1.0.0 // indirect | ||
github.com/joho/godotenv v1.5.1 // indirect | ||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect | ||
github.com/magiconair/properties v1.8.0 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mattn/go-zglob v0.0.4 // indirect | ||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect | ||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect | ||
github.com/mitchellh/mapstructure v1.1.2 // indirect | ||
github.com/pelletier/go-toml v1.2.0 // indirect | ||
github.com/radovskyb/watcher v1.0.7 // indirect | ||
github.com/sajari/fuzzy v1.0.0 // indirect | ||
github.com/spf13/afero v1.1.2 // indirect | ||
github.com/spf13/cast v1.3.0 // indirect | ||
github.com/spf13/cobra v0.0.5 // indirect | ||
github.com/spf13/jwalterweatherman v1.0.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/spf13/viper v1.3.2 // indirect | ||
github.com/zclconf/go-cty v1.13.0 // indirect | ||
github.com/zeebo/xxh3 v1.0.2 // indirect | ||
golang.org/x/sync v0.6.0 // indirect | ||
golang.org/x/sys v0.17.0 // indirect | ||
golang.org/x/term v0.17.0 // indirect | ||
golang.org/x/text v0.11.0 // indirect | ||
gopkg.in/yaml.v2 v2.2.7 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
mvdan.cc/sh/v3 v3.8.0 // indirect | ||
) |
Oops, something went wrong.