Skip to content

Commit 0199683

Browse files
better0fdeadLeonidVas
authored andcommitted
ci: add license checker
We need to check the licenses of modules that came from dependencies. CI should return an error if the licenses are not in the list: BSD-2 MIT Apache-2.0 BSD MPL-2.0 Closes #737
1 parent 004186a commit 0199683

File tree

4 files changed

+55
-8
lines changed

4 files changed

+55
-8
lines changed

.github/workflows/tests.yml

+16
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ jobs:
101101
if: matrix.tests == 'other'
102102
run: mage lint
103103

104+
- name: Build cartridge
105+
run: mage build
106+
107+
- name: License checker
108+
run: |
109+
go install github.com/uw-labs/lichen@latest
110+
mage checklicenses
111+
104112
- name: Unit tests
105113
if: matrix.tests == 'other'
106114
run: mage unit
@@ -198,6 +206,14 @@ jobs:
198206
if: matrix.tests == 'other'
199207
run: mage lint
200208

209+
- name: Build cartridge
210+
run: mage build
211+
212+
- name: License checker
213+
run: |
214+
go install github.com/uw-labs/lichen@latest
215+
mage checklicenses
216+
201217
- name: Unit tests
202218
if: matrix.tests == 'other'
203219
run: mage unit

.lichen.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
allow:
2+
- "MIT"
3+
- "Apache-2.0"
4+
- "BSD-3-Clause"
5+
- "BSD-2-Clause"
6+
- "MPL-2.0"
7+
- "CC-BY-SA-4.0"
8+
override:
9+
- path: "github.com/robfig/config"
10+
licenses: ["MPL-2.0"]

README.dev.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@
1919
rpm --version
2020
cpio --version
2121
```
22-
22+
2323
4. Install [git](https://git-scm.com/downloads).
2424
```bash
2525
git --version
2626
```
27-
27+
2828
5. Install [docker](https://www.docker.com/get-started).
2929
```bash
3030
docker --version
3131
```
32-
32+
3333
6. Install [Tarantool](https://www.tarantool.io/en/download/os-installation/) (1.10 or 2.x version).
3434
```bash
3535
tarantool --version
@@ -43,7 +43,7 @@
4343
```bash
4444
export PATH=$(go env GOPATH)/bin:$PATH
4545
```
46-
46+
4747
8. Install [pytest](https://docs.pytest.org/en/6.2.x/getting-started.html).
4848
```bash
4949
python3 -m pytest --version
@@ -54,23 +54,28 @@
5454
git clone [email protected]:tarantool/cartridge-cli.git
5555
cd ./cartridge-cli
5656
```
57-
57+
5858
10. To run tests, git user must be configured. For example,
5959
```bash
6060
git config --global user.email "[email protected]"
6161
git config --global user.name "Tar Antool"
6262
```
63-
63+
6464
11. Install pytest dependencies.
6565
```bash
6666
pip3 install -r test/requirements.txt
6767
```
68-
68+
6969
12. Install luacheck.
7070
```bash
7171
tarantoolctl rocks install luacheck
7272
```
7373

74+
13. Install lichen.
75+
```bash
76+
go install github.com/uw-labs/lichen@latest
77+
```
78+
7479
All remaining dependencies (like code generation) will be invoked with mage if needed.
7580

7681
### Test run

magefile.go

+17-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ func GenerateGoCode() error {
124124
return nil
125125
}
126126

127+
// Run license checker.
128+
func CheckLicenses() error {
129+
fmt.Println("Running license checker...")
130+
131+
home, err := os.UserHomeDir()
132+
if err != nil {
133+
return err
134+
}
135+
136+
if err := sh.RunV(home+"/go/bin/lichen", "--config", ".lichen.yaml", "cartridge"); err != nil {
137+
return err
138+
}
139+
140+
return nil
141+
}
142+
127143
// Run go vet and flake8
128144
func Lint() error {
129145
mg.Deps(GenerateGoCode)
@@ -195,7 +211,7 @@ func E2e() error {
195211

196212
// Run all tests
197213
func Test() {
198-
mg.SerialDeps(Lint, Unit, Integration, TestExamples, E2e)
214+
mg.SerialDeps(Lint, CheckLicenses, Unit, Integration, TestExamples, E2e)
199215
}
200216

201217
// Build cartridge-cli executable

0 commit comments

Comments
 (0)