GoogleCloudPlatform / GoogleCloudPlatform/professional-services

Running local lint checks prior to raising PR

Open
#523 1 comment 0 reactions 2 assignees Claimed by @tswast View on GitHub
Dominant language
Python
Stars
3.1k
Forks
1.5k
Avg merge
2d 8h
Merged PRs (30d)
44

Description

**Issue**

Today when user submits a pull request to professional services repo, lint checks are executed via cloud build trigger inside google cloud project owned by repo maintainers. In case of failures, PR authors do not have visibility for the failure reasons.

To resolve this we have recommendation in [Contribution](https://github.com/GoogleCloudPlatform/professional-services/blob/master/CONTRIBUTING.md ) section to run local lint checks. But this process has multiple steps and dependencies on terraform and docker to be available.

**Proposal**

Build a linitchecker.yaml that PR author can run locally using single gcloud command without need for terraform and docker

#linitchecker.yaml
```
steps:
# Step 0: Pull image if exists
- name: gcr.io/cloud-builders/docker
entrypoint: 'bash'
args: ['-c', 'docker pull gcr.io/$PROJECT_ID/${_IMAGE_NAME}:${_IMAGE_VERSION} || exit 0']

# Step 1: Create docker image with required tools
- name: gcr.io/cloud-builders/docker
args:
- 'build'
- '--tag=gcr.io/$PROJECT_ID/${_IMAGE_NAME}:${_IMAGE_VERSION}'
- '--cache-from=gcr.io/$PROJECT_ID/${_IMAGE_NAME}:${_IMAGE_VERSION}'
- '--file=cloudbuild/Dockerfile'
- '.'
# Step 2: Run lint check
- name: gcr.io/$PROJECT_ID/${_IMAGE_NAME}
args: ["test"]

substitutions:
# Default values
_IMAGE_NAME: 'professionalservices-lintcheck'
_IMAGE_VERSION: 'latest'

timeout: 900s
images: ['gcr.io/$PROJECT_ID/${_IMAGE_NAME}:${_IMAGE_VERSION}']
```

Run the gcloud command: ```gcloud builds submit --config lintchecker.yaml . ```

If we are planning to move forward with dynamic cloud build, rebase checks can also be included so that author has complete visibility on all the checks before PR submission

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.