Skip to content

Commit

Permalink
Check dependency licenses in CIs
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrobdod committed Apr 12, 2024
1 parent 6dc3a54 commit 445a106
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.awk text diff=awk
*.md text diff=markdown
*.png binary diff=png -filter
*.rs text diff=rust filter=rustfmt
Expand Down
18 changes: 18 additions & 0 deletions .github/license-acceptable.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BEGIN {FS="\t"}
{
isAcceptable=0
split($5, licenseOptions, " OR ")
for (i in licenseOptions) {
isAcceptable = isAcceptable ||
licenseOptions[i] == "Apache-2.0" ||
licenseOptions[i] == "BSD-3-Clause" ||
licenseOptions[i] == "MIT" ||
licenseOptions[i] == "license"
# "license" is the value of the header of this TSV column
}
if (! isAcceptable) {
print($1)
print($5)
exit 3
}
}
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,20 @@ jobs:
cargo-ubuntu-
- name: cargo clippy
run: cargo clippy --all-targets --all-features -- -D warnings
check_licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: ~/.cargo/registry/
key: cargo-ubuntu-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-ubuntu-
- name: Install cargo-license
run: 'cargo install cargo-license'
- name: Check licenses
run: >
cargo license --tsv |
awk -f .github/license-acceptable.awk
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install:
./rustup.sh -y --default-toolchain $CHANNEL --default-host $TARGET
source $HOME/.cargo/env
- ps: '& cargo -V'
- ps: '& cargo install -q cargo-license'

build_script:
- cmd: 'cargo build %MODE%'
Expand All @@ -47,6 +48,8 @@ test_script:

- ps: 'cargo fmt --all -- --check'

- ps: 'cargo license --tsv | awk -f .github/license-acceptable.awk'

- ps: './target/release/png_inflate --version'
artifacts:
- path: target\release\png_inflate.exe.gz
Expand Down
1 change: 1 addition & 0 deletions lib/png_inflate_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ authors = [
]
edition = "2021"
publish = false
license = "Apache-2.0"

[lib]
proc-macro = true

0 comments on commit 445a106

Please sign in to comment.