From a56a05ae0df54d4d3545179e1037351168aaa4d9 Mon Sep 17 00:00:00 2001 From: Mahruf Iqbal <102766665+mahrufiqbalHO@users.noreply.github.com> Date: Fri, 30 Sep 2022 09:34:48 +0100 Subject: [PATCH] refactor: update workflow to use jsonnet fmt/lint container image (#263) * refactor: update workflow to use jsonnet fmt/lint container image * refactor: add fmt/lint version --- .github/workflows/docker-build-branch.yml | 30 ++--------------------- monitoring-as-code/fmt.sh | 2 +- monitoring-as-code/lint.sh | 2 +- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/.github/workflows/docker-build-branch.yml b/.github/workflows/docker-build-branch.yml index c734ed27..b6111fb9 100644 --- a/.github/workflows/docker-build-branch.yml +++ b/.github/workflows/docker-build-branch.yml @@ -30,39 +30,13 @@ jobs: with: dockerfile: ./monitoring-as-code/Dockerfile - - uses: actions/setup-go@v3 - - - name: Set up jsonnet - run: | - go install github.com/google/go-jsonnet/cmd/jsonnet@v0.17.0 - go install github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb@v0.5.1 - go install github.com/google/go-jsonnet/cmd/jsonnetfmt@v0.17.0 - go install github.com/google/go-jsonnet/cmd/jsonnet-lint@v0.18.0 - - eval "$(go env)" - PATH=$PATH:$GOPATH/bin - - jb init - jb install https://github.com/grafana/grafonnet-lib/grafonnet - jb install https://github.com/grafana/jsonnet-libs/grafana-builder - - name: Jsonnet format check run: | - eval "$(go env)" - PATH=$PATH:$GOPATH/bin - - jsonnetfmt -v - - find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | xargs -n 1 jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s --no-sort-imports -i && git diff --exit-code --color + sh ${{ github.workspace }}/monitoring-as-code/fmt.sh && git diff --exit-code --color - name: Jsonnet lint check run: | - eval "$(go env)" - PATH=$PATH:$GOPATH/bin - - jsonnet-lint -v - - find . -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | xargs -n 1 jsonnet-lint -J vendor + sh ${{ github.workspace }}/monitoring-as-code/lint.sh #Logs into Github registry - name: Login to GitHub Container Registry diff --git a/monitoring-as-code/fmt.sh b/monitoring-as-code/fmt.sh index 4bbbe793..2729f94a 100755 --- a/monitoring-as-code/fmt.sh +++ b/monitoring-as-code/fmt.sh @@ -1,4 +1,4 @@ #!/bin/sh set -e -echo "find . -name 'pkg' -prune -o -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | xargs -n 1 jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s --no-sort-imports -i" | docker run -i -v "$(pwd):/app/MaC" jsonnet-dev-tool /bin/sh +echo "jsonnetfmt -v && find . -name 'pkg' -prune -o -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | xargs -n 1 jsonnetfmt -n 2 --max-blank-lines 2 --string-style s --comment-style s --no-sort-imports -i" | docker run -i -v "$(pwd):/app/MaC" ghcr.io/ho-cto/sre-fmt-lint:latest /bin/sh diff --git a/monitoring-as-code/lint.sh b/monitoring-as-code/lint.sh index 90000f63..8d73ac4c 100755 --- a/monitoring-as-code/lint.sh +++ b/monitoring-as-code/lint.sh @@ -1,4 +1,4 @@ #!/bin/sh set -e -echo "find . -name 'pkg' -prune -o -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | xargs -n 1 jsonnet-lint -J vendor" | docker run -i -v "$(pwd):/app/MaC" jsonnet-dev-tool /bin/sh \ No newline at end of file +echo "jsonnet-lint -v && find . -name 'pkg' -prune -o -name 'vendor' -prune -o -name '*.libsonnet' -print -o -name '*.jsonnet' -print | xargs -n 1 jsonnet-lint -J vendor" | docker run -i -v "$(pwd):/app/MaC" ghcr.io/ho-cto/sre-fmt-lint:latest /bin/sh \ No newline at end of file