Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

secrethub/golangci-worker

 
 

Repository files navigation

CircleCI GolangCI

Worker

This repository contains code of queue worker. Worker runs golangci-lint and reports result to GitHub.

Development

Technologies

Go (golang), heroku, circleci, docker, redis, postgres.

Preparation

In golangci-api repo run:

docker-compose up -d

It runs postgres and redis needed for both api and worker.

How to run worker

make run_dev

How to run once on GitHub repo without changing GitHub data: commit status, comments

REPO={OWNER/NAME} PR={PULL_REQUEST_NUMBER} make test_repo_fake_github

e.g. REPO=golangci/golangci-worker PR=39 make test_repo_fake_github

How to run analysis of pull request locally

# in golangci-api repo
godotenv -f .env go run ./scripts/emulate_webhook/main.go -repo golangci/golangci-lint -pr 292 -sha 7b605d5c6f5a524e6b0a9cc12ad747222375ad54

Configuration

Configurate via .env file. Dev .env may be like this:

REDIS_URL="redis://localhost:6379"
API_URL="https://api.dev.golangci.com"
WEB_ROOT="https://dev.golangci.com"
USE_CONTAINER_EXECUTOR_PERCENT=100
USE_NEW_REPO_ANALYSIS_PERCENT=100
ORCHESTRATOR_ADDR="http://127.0.0.1:8001"
ORCHESTRATOR_TOKEN=secret_token

Executors

Executor is an abstration allowing to run arbitrary shell commands. We support following executor types:

  1. shell - runs commands on a local machine
  2. remote shell - runs commands on the specified remote host; it's currently the primary executor
  3. container - runs commands by sending them to containers orchestrator; containers orchestrator runs container for executing commands; currently we migrate to this executor type.

The recommended way to run executors during development:

# in golangci-api repo
TOKEN=secret_token go run ./cmd/containers_orchestrator/main.go

API

golangci-api is not needed for running and testing golangci-worker. Not running api can just make log warnings like this:

level=warning msg="Can't get current state: bad status code 404"

Testing

To run tests:

make test

For more realistic testing than test_repo_fake_github use in golangci-api repo GitHub WebHook emulator:

go run app/scripts/emulate_webhook/main.go --repo golangci/golangci-worker --pr 39 --sha fbd0d7bada8a6cfa7adbc58e5901e0d66f7f65b1

Contributing

See CONTRIBUTING.

About

Queue worker of GolangCI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 97.4%
  • Dockerfile 1.5%
  • Other 1.1%