diff --git a/.github/workflows/build_playground_backend.yml b/.github/workflows/build_playground_backend.yml index bd2868768246..48eab26b2a9e 100644 --- a/.github/workflows/build_playground_backend.yml +++ b/.github/workflows/build_playground_backend.yml @@ -19,7 +19,6 @@ on: push: tags: 'v*' pull_request: - tags: 'v*' paths: ['playground/backend/**'] workflow_dispatch: @@ -30,6 +29,7 @@ jobs: env: GO_VERSION: 1.17.0 BEAM_VERSION: 2.33.0 + TERRAFORM_VERSION: 1.0.9 steps: - name: Check out the repo uses: actions/checkout@v2 @@ -40,17 +40,11 @@ jobs: - uses: actions/setup-go@v2 with: go-version: '${{ env.GO_VERSION }}' - - name: Prepare Go lint env - run: "sudo ./playground/backend/env_setup.sh" - - name: Run Lint -# run: "golangci-lint run internal/..." - run: "golangci-lint run cmd/server/..." - working-directory: playground/backend/ - name: Remove default github maven configuration # This step is a workaround to avoid a decryption issue run: rm ~/.m2/settings.xml - - name: Run Tests - run: ./gradlew playground:backend:test + - name: Run PreCommit + run: ./gradlew playground:backend:precommit - name: install npm uses: actions/setup-node@v2 with: @@ -60,6 +54,10 @@ jobs: - name: lint dockerfile run: dockerlint Dockerfile working-directory: playground/backend/containers/java + - uses: hashicorp/setup-terraform@v1 + with: + terraform_version: ${{ env.TERRAFORM_VERSION }} + if: startsWith(github.ref, 'ref/tags/') - name: Setup GCP account run: echo ${{ secrets.GCP_ACCESS_KEY }} | base64 -d > /tmp/gcp_access.json if: startsWith(github.ref, 'ref/tags/') diff --git a/.github/workflows/build_playground_frontend.yml b/.github/workflows/build_playground_frontend.yml index f93e330442b0..ee1bed8f2b5a 100644 --- a/.github/workflows/build_playground_frontend.yml +++ b/.github/workflows/build_playground_frontend.yml @@ -19,7 +19,6 @@ on: push: tags: 'v*' pull_request: - tags: 'v*' paths: ['playground/frontend/**'] workflow_dispatch: @@ -30,6 +29,7 @@ jobs: env: GO_VERSION: 1.17.0 BEAM_VERSION: 2.33.0 + TERRAFORM_VERSION: 1.0.9 steps: - name: Check out the repo uses: actions/checkout@v2 @@ -41,10 +41,8 @@ jobs: uses: subosito/flutter-action@v1 with: channel: 'stable' - - name: Run Lint - run: ./gradlew playground:frontend:analyze - - name: Run Tests - run: ./gradlew playground:frontend:test + - name: Run PreCommit + run: ./gradlew playground:frontend:precommit - name: install npm uses: actions/setup-node@v2 with: @@ -54,6 +52,10 @@ jobs: - name: lint dockerfile run: dockerlint Dockerfile working-directory: playground/frontend + - uses: hashicorp/setup-terraform@v1 + with: + terraform_version: ${{ env.TERRAFORM_VERSION }} + if: startsWith(github.ref, 'ref/tags/') - name: Setup GCP account run: echo ${{ secrets.GCP_ACCESS_KEY }} | base64 -d > /tmp/gcp_access.json if: startsWith(github.ref, 'ref/tags/') diff --git a/build.gradle.kts b/build.gradle.kts index 25029151eaa2..37e0164a6749 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -248,12 +248,8 @@ task("goIntegrationTests") { } task("playgroundPreCommit") { - dependsOn(":playground:backend:tidy") - dependsOn(":playground:backend:test") - - dependsOn(":playground:frontend:pubGet") - dependsOn(":playground:frontend:analyze") - dependsOn(":playground:frontend:test") + dependsOn(":playground:backend:precommit") + dependsOn(":playground:frontend:precommit") } task("pythonPreCommit") { diff --git a/playground/backend/build.gradle.kts b/playground/backend/build.gradle.kts index 0547b7cb1c77..e73b00e9b532 100644 --- a/playground/backend/build.gradle.kts +++ b/playground/backend/build.gradle.kts @@ -50,3 +50,28 @@ task("test") { } } } + +task("installLinter") { + doLast { + exec { + executable("sh") + args("env_setup.sh") + } + } +} + +task("runLint") { + dependsOn(":playground:backend:installLinter") + doLast { + exec { + executable("golangci-lint") + args("run", "cmd/server/...") + } + } +} +task("precommit") { + dependsOn(":playground:backend:runLint") + dependsOn(":playground:backend:tidy") + dependsOn(":playground:backend:test") +} + diff --git a/playground/backend/env_setup.sh b/playground/backend/env_setup.sh index f12af691f739..1b87b319bcf9 100755 --- a/playground/backend/env_setup.sh +++ b/playground/backend/env_setup.sh @@ -17,12 +17,18 @@ GO_LINTER_VERSION=1.42.1 # Install GO Linter -wget https://github.com/golangci/golangci-lint/releases/download/v1.42.1/golangci-lint-$GO_LINTER_VERSION-linux-amd64.deb -dpkg -i golangci-lint-$GO_LINTER_VERSION-linux-amd64.deb +#wget https://github.com/golangci/golangci-lint/releases/download/v1.42.1/golangci-lint-$GO_LINTER_VERSION-linux-amd64.deb +#dpkg -i golangci-lint-$GO_LINTER_VERSION-linux-amd64.deb -# Install Terraform -apt-get install -y gnupg software-properties-common curl -curl -fsSL https://apt.releases.hashicorp.com/gpg | apt-key add - -apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" -apt-get update -apt-get install -y terraform +kernelname=$(uname -s) + +# Running on Linux +if [ "$kernelname" = "Linux" ]; then + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v$GO_LINTER_VERSION + +# Running on Mac +elif [ "$kernelname" = "Darwin" ]; then + brew tap golangci/tap + brew install golangci/tap/golangci-lint +else echo "Unrecognized Kernel Name: $kernelname" +fi diff --git a/playground/frontend/build.gradle b/playground/frontend/build.gradle index 98e8b929e016..c46f60511635 100644 --- a/playground/frontend/build.gradle +++ b/playground/frontend/build.gradle @@ -92,6 +92,12 @@ task test { } } +task precommit { + dependsOn(":playground:frontend:pubGet") + dependsOn(":playground:frontend:analyze") + dependsOn(":playground:frontend:test") +} + task copyDockerfileDependencies(type: Copy) { group = "build" description = "Copy files that required to build docker container"