fix this using deployer #140
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
name: Checks | |
on: | |
pull_request: | |
push: | |
env: | |
DOCKER_BUILDKIT: '1' | |
GO_VERSION: '1.20' | |
GOLANGCI_LINT_VERSION: v1.51.1 | |
# This workflow runs for not-yet-reviewed external contributions and so it | |
# intentionally has no write access and only limited read access to the | |
# repository. | |
permissions: | |
contents: read | |
# Annotations | |
# 2 warnings | |
# build | |
# Unexpected input(s) 'cache', valid inputs are ['go-version', 'check-latest', 'stable', 'token'] | |
jobs: | |
lint: | |
name: "lint" | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Fetch source code" | |
uses: actions/checkout@v3 | |
- name: Install Go toolchain | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{env.GO_VERSION}} | |
check-latest: true | |
cache: true | |
- name: "go fmt check" | |
shell: bash | |
run: | | |
files=$(go fmt ./...) | |
if [ -n "$files" ]; then | |
echo "The following file(s) do not conform to go fmt:" | |
echo "$files" | |
exit 1 | |
fi | |
- name: "go vet" | |
shell: bash | |
run: | | |
go vet ./... | |
- name: "go.mod and go.sum consistency check" | |
shell: bash | |
run: | | |
go mod tidy | |
if [[ -n "$(git status --porcelain)" ]]; then | |
echo >&2 "ERROR: go.mod/go.sum are not up-to-date. Run 'go mod tidy' and then commit the updated files." | |
exit 1 | |
fi | |
- name: "Download golang-lint" | |
shell: bash | |
run: | | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin ${{ env.GOLANGCI_LINT_VERSION }} | |
golangci-lint version | |
- name: "lint" | |
shell: bash | |
run: | | |
golangci-lint run -v | |
unit-tests: | |
name: "Unit Tests" | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Fetch source code" | |
uses: actions/checkout@v3 | |
- name: Install Go toolchain | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{env.GO_VERSION}} | |
check-latest: true | |
cache: true | |
- name: "Unit tests" | |
shell: bash | |
run: | | |
go test ./... | |
build-test-config-matrix: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Fetch source code" | |
uses: actions/checkout@v3 | |
- id: set-matrix | |
shell: bash | |
run: | | |
cd test-configs | |
v="" | |
for f in config.*.hcl; do | |
if [[ -n "$v" ]]; then | |
v="${v}, \"${f}\"" | |
else | |
v="\"${f}\"" | |
fi | |
done | |
echo "$v" | |
echo "config_file_matrix=[$v]" >> $GITHUB_OUTPUT | |
outputs: | |
config_file_matrix: ${{ steps.set-matrix.outputs.config_file_matrix }} | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Fetch source code" | |
uses: actions/checkout@v3 | |
- name: Install Go toolchain | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{env.GO_VERSION}} | |
check-latest: true | |
cache: true | |
- name: compile binary | |
shell: bash | |
run: | | |
make | |
mv $(which devconsul) /usr/local/bin | |
mv ./bin/clustertool /usr/local/bin | |
devconsul help | |
clustertool catalog-sync -h | |
- name: upload devconsul binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: devconsul | |
path: /usr/local/bin/devconsul | |
if-no-files-found: error | |
- name: upload clustertool binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: clustertool | |
path: /usr/local/bin/clustertool | |
if-no-files-found: error | |
get-consul-binary: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: fetch consul | |
shell: bash | |
run: | | |
docker pull hashicorp/consul:latest | |
docker tag hashicorp/consul:latest consul-dev:latest | |
docker rm -f consul-extract || true | |
docker create --name consul-extract consul-dev:latest | |
docker cp consul-extract:/bin/consul "/usr/local/bin/consul" | |
docker rm -f consul-extract || true | |
- name: upload binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: consul | |
path: /usr/local/bin/consul | |
if-no-files-found: error | |
configuration-tests: | |
name: "Config File Tests" | |
runs-on: ubuntu-22.04 | |
needs: [ build, get-consul-binary, build-test-config-matrix ] | |
strategy: | |
fail-fast: false | |
matrix: | |
config_file: ${{ fromJson(needs.build-test-config-matrix.outputs.config_file_matrix) }} | |
steps: | |
- name: "Fetch source code" | |
uses: actions/checkout@v3 | |
- name: download devconsul binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: devconsul | |
path: /usr/local/bin/ | |
- name: download clustertool binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: clustertool | |
path: ./bin/ | |
- name: download consul binary | |
uses: actions/download-artifact@v3 | |
with: | |
name: consul | |
path: /usr/local/bin/ | |
- name: fix permissions | |
shell: bash | |
run: | | |
chmod 755 /usr/local/bin/devconsul /usr/local/bin/consul ./bin/clustertool | |
consul version | |
devconsul help | |
./bin/clustertool catalog-sync -h | |
- name: test container | |
timeout-minutes: 10 | |
shell: bash | |
run: | | |
docker pull consul:latest | |
docker tag consul:latest consul-dev:latest | |
./test-configs/test.sh "${{matrix.config_file}}" | |
- name: capture failed container logs | |
if: failure() | |
shell: bash | |
run: | | |
cd test-configs | |
devconsul dump-logs || true | |
cp -a cache cache-output | |
devconsul down &>/dev/null || true | |
- uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: "docker-logs-${{matrix.config_file}}" | |
path: ./test-configs/logs | |
if-no-files-found: ignore | |
- uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: "run-cache-${{matrix.config_file}}" | |
path: ./test-configs/cache-output | |
if-no-files-found: ignore |