diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c21c1b7df..de8051e361 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,6 +51,9 @@ jobs: - name: Check unused dependencies uses: bnjbvr/cargo-machete@main + - name: Check licenses are present + run: script/check-licenses + - name: Check license generation run: script/generate-licenses /tmp/zed_licenses_output @@ -87,7 +90,7 @@ jobs: clean: false - name: cargo clippy - run: cargo xtask clippy + run: ./script/clippy - name: Run tests uses: ./.github/actions/run_tests @@ -114,7 +117,7 @@ jobs: clean: false - name: cargo clippy - run: cargo xtask clippy + run: ./script/clippy - name: Run tests uses: ./.github/actions/run_tests @@ -139,7 +142,7 @@ jobs: save-if: ${{ github.ref == 'refs/heads/main' }} - name: cargo clippy - run: cargo xtask clippy + run: ./script/clippy - name: Build Zed run: cargo build -p zed diff --git a/.github/workflows/deploy_collab.yml b/.github/workflows/deploy_collab.yml index bd35270408..654532e2ae 100644 --- a/.github/workflows/deploy_collab.yml +++ b/.github/workflows/deploy_collab.yml @@ -27,7 +27,7 @@ jobs: uses: ./.github/actions/check_style - name: Run clippy - run: cargo xtask clippy + run: ./script/clippy tests: name: Run tests diff --git a/.github/workflows/release_nightly.yml b/.github/workflows/release_nightly.yml index ae74dc7767..61f224ecb0 100644 --- a/.github/workflows/release_nightly.yml +++ b/.github/workflows/release_nightly.yml @@ -32,7 +32,7 @@ jobs: uses: ./.github/actions/check_style - name: Run clippy - run: cargo xtask clippy + run: ./script/clippy tests: timeout-minutes: 60 name: Run tests diff --git a/.zed/tasks.json b/.zed/tasks.json index 80465969e2..259ab07f3e 100644 --- a/.zed/tasks.json +++ b/.zed/tasks.json @@ -1,7 +1,7 @@ [ { "label": "clippy", - "command": "cargo", - "args": ["xtask", "clippy"] + "command": "./script/clippy", + "args": [] } ] diff --git a/script/check-licenses b/script/check-licenses new file mode 100755 index 0000000000..85dcca1760 --- /dev/null +++ b/script/check-licenses @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -euo pipefail + +check_license () { + for license in "LICENSE-AGPL" "LICENSE-GPL" "LICENSE-APACHE"; do + if [[ -L "$1/$license" ]]; then + return 0 + elif [[ -e "$1/$license" ]]; then + echo "Error: $1/$license exists but is not a symlink." + exit 1 + fi + done + echo "Error: $1 does not contain a license symlink" + exit 1 +} + +git ls-files **/*/Cargo.toml | while read cargo_toml; do + check_license $(dirname "$cargo_toml"); +done diff --git a/script/clippy b/script/clippy index 90a121be1c..e81dccf2df 100755 --- a/script/clippy +++ b/script/clippy @@ -1,5 +1,10 @@ #!/usr/bin/env bash -set -euxo pipefail +set -euo pipefail -cargo xtask clippy +if [[ ! " $* " == *" -p "* && ! " $* " == *" --package "* ]]; then + set -- "$@" --workspace +fi + +set -x +"${CARGO:-cargo}" clippy "$@" --release --all-targets --all-features -- --deny warnings