|
1 | 1 | [](https://circleci.com/gh/golangci/golangci-worker)
|
2 | 2 | [](https://golangci.com)
|
3 | 3 |
|
4 |
| -## Worker |
| 4 | +# Worker |
| 5 | + |
5 | 6 | This repository contains code of queue worker. Worker runs golangci-lint and reports result to GitHub.
|
6 | 7 |
|
7 | 8 | ## Development
|
| 9 | + |
8 | 10 | ### Technologies
|
| 11 | + |
9 | 12 | Go (golang), heroku, circleci, docker, redis, postgres.
|
10 | 13 |
|
11 | 14 | ### Preparation
|
| 15 | + |
12 | 16 | In [golangci-api](https://github.com/golangci/golangci-api) repo run:
|
13 |
| -``` |
| 17 | + |
| 18 | +```bash |
14 | 19 | docker-compose up -d
|
15 | 20 | ```
|
| 21 | + |
16 | 22 | It runs postgres and redis needed for both api and worker.
|
17 | 23 |
|
18 | 24 | ### How to run worker
|
| 25 | + |
19 | 26 | ```bash
|
20 | 27 | make run_dev
|
21 | 28 | ```
|
22 | 29 |
|
23 | 30 | ### How to run once on GitHub repo without changing GitHub data: commit status, comments
|
24 |
| -``` |
| 31 | + |
| 32 | +```bash |
25 | 33 | REPO={OWNER/NAME} PR={PULL_REQUEST_NUMBER} make test_repo_fake_github
|
26 | 34 | ```
|
27 | 35 |
|
28 | 36 | e.g. `REPO=golangci/golangci-worker PR=39 make test_repo_fake_github`
|
29 | 37 |
|
30 | 38 | ### Configuration
|
| 39 | + |
31 | 40 | Configurate via `.env` file. Dev `.env` may be like this:
|
32 |
| -``` |
| 41 | + |
| 42 | +```bash |
33 | 43 | REDIS_URL="redis://localhost:6379"
|
34 | 44 | API_URL="https://api.dev.golangci.com"
|
35 | 45 | WEB_ROOT="https://dev.golangci.com"
|
36 | 46 | USE_DOCKER_EXECUTOR=1
|
37 | 47 | ```
|
38 | 48 |
|
39 | 49 | ### Executors
|
| 50 | + |
40 | 51 | Executor is an abstraction over executing shell commands. In production we use remote shell executor (machine by ssh).
|
41 | 52 | For local development it's better to use docker executor:
|
42 |
| -``` |
| 53 | + |
| 54 | +```bash |
43 | 55 | docker build -t golangci_executor -f app/docker/executor.dockerfile .
|
44 | 56 | echo "USE_DOCKER_EXECUTOR=1" >>.env
|
45 | 57 | ```
|
46 | 58 |
|
47 | 59 | ### API
|
| 60 | + |
48 | 61 | golangci-api is not needed for running and testing golangci-worker. Not running api can just make log warnings like this:
|
49 |
| -``` |
| 62 | + |
| 63 | +```bash |
50 | 64 | level=warning msg="Can't get current state: bad status code 404"
|
51 | 65 | ```
|
52 | 66 |
|
53 | 67 | ### Testing
|
| 68 | + |
54 | 69 | To run tests:
|
55 |
| -``` |
| 70 | + |
| 71 | +```bash |
56 | 72 | make test
|
57 | 73 | ```
|
58 | 74 |
|
59 | 75 | For more realistic testing than `test_repo_fake_github` use in golangci-api repo GitHub WebHook emulator:
|
60 |
| -``` |
| 76 | + |
| 77 | +```bash |
61 | 78 | go run app/scripts/emulate_webhook/main.go --repo golangci/golangci-worker --pr 39 --sha fbd0d7bada8a6cfa7adbc58e5901e0d66f7f65b1
|
62 | 79 | ```
|
63 | 80 |
|
| 81 | +## Contributing |
64 | 82 |
|
65 |
| -# Contributing |
66 | 83 | See [CONTRIBUTING](https://github.com/golangci/golangci-worker/blob/master/CONTRIBUTING.md).
|
67 |
| - |
|
0 commit comments