From ebdae6094ecc105be10fb2e59b13cf63773a4c10 Mon Sep 17 00:00:00 2001 From: Samson <16504129+sagudev@users.noreply.github.com> Date: Fri, 23 Aug 2024 10:58:12 +0200 Subject: [PATCH] CI: Add separate Lint&Tidy check and remove test-tidy from linux (#33150) * Create separate Lint&Tidy check Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Remove quick-check as it's not longer relevant Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Add clippy to rust-toolchain Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * fix try parser test expectations Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * use lint in result Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Lint & Tidy -> Lint Co-authored-by: Martin Robinson Signed-off-by: Samson <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Signed-off-by: Samson <16504129+sagudev@users.noreply.github.com> Co-authored-by: Martin Robinson --- .github/workflows/android.yml | 14 ++---- .github/workflows/dispatch-workflow.yml | 6 +++ .github/workflows/lint.yml | 59 +++++++++++++++++++++++++ .github/workflows/linux.yml | 19 ++------ .github/workflows/mac.yml | 14 ++---- .github/workflows/main.yml | 6 +++ .github/workflows/ohos.yml | 14 ++---- .github/workflows/quick-check.yml | 16 ------- .github/workflows/try.yml | 1 + .github/workflows/windows.yml | 13 +----- python/servo/try_parser.py | 16 +++++-- rust-toolchain.toml | 1 + 12 files changed, 100 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/quick-check.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 72b7008eb88..eb88fd240ab 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -50,20 +50,12 @@ jobs: fetch-depth: 2 - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.4 - - name: Install taplo - uses: baptiste0928/cargo-install@v3 - with: - crate: taplo-cli - locked: true - - name: Install cargo-deny - uses: baptiste0928/cargo-install@v3 - with: - crate: cargo-deny - locked: true + - name: Install crown + run: cargo install --path support/crown - name: Bootstrap Python run: python3 -m pip install --upgrade pip virtualenv - name: Bootstrap dependencies - run: sudo apt update && python3 ./mach bootstrap + run: sudo apt update && python3 ./mach bootstrap --skip-lints - name: Set up JDK 17 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/dispatch-workflow.yml b/.github/workflows/dispatch-workflow.yml index 701ce6021c5..d66ea68f94b 100644 --- a/.github/workflows/dispatch-workflow.yml +++ b/.github/workflows/dispatch-workflow.yml @@ -50,6 +50,12 @@ jobs: unit-tests: ${{ inputs.unit-tests }} wpt-args: ${{ inputs.wpt-args }} + lint: + if: ${{ inputs.workflow == 'lint' }} + name: Lint + uses: ./.github/workflows/lint.yml + secrets: inherit + android: if: ${{ inputs.workflow == 'android' }} name: Android diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000000..02495d4ba8b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,59 @@ +name: Lint +on: + workflow_call: + workflow_dispatch: + +env: + RUST_BACKTRACE: 1 + SHELL: /bin/bash + SCCACHE_GHA_ENABLED: "true" + RUSTC_WRAPPER: "sccache" + CCACHE: "sccache" + CARGO_INCREMENTAL: 0 + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + if: github.event_name != 'pull_request_target' + with: + fetch-depth: 2 # This is necessary for `test-tidy`. + # This is necessary to checkout the pull request if this run was triggered via a + # `pull_request_target` event. + - uses: actions/checkout@v4 + if: github.event_name == 'pull_request_target' + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 2 # This is necessary for `test-tidy`. + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.4 + - name: Set LIBCLANG_PATH env # needed for bindgen in mozangle + run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install taplo + uses: baptiste0928/cargo-install@v3 + with: + crate: taplo-cli + locked: true + - name: Install cargo-deny + uses: baptiste0928/cargo-install@v3 + with: + crate: cargo-deny + locked: true + - name: Bootstrap Python + run: python3 -m pip install --upgrade pip + - name: Bootstrap dependencies + run: | + sudo apt update + python3 ./mach bootstrap + # TODO: Do GitHub anotaions + # TODO: Fail on warnings + - name: Clippy + run: | + python3 ./mach cargo-clippy --use-crown --locked + - name: Tidy + run: python3 ./mach test-tidy --no-progress --all \ No newline at end of file diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 3002bac0bee..6a0002361c8 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -74,15 +74,12 @@ jobs: steps: - uses: actions/checkout@v4 if: github.event_name != 'pull_request_target' - with: - fetch-depth: 2 # This is necessary for `test-tidy`. # This is necessary to checkout the pull request if this run was triggered via a # `pull_request_target` event. - uses: actions/checkout@v4 if: github.event_name == 'pull_request_target' with: ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 2 # This is necessary for `test-tidy`. - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.4 - name: Set LIBCLANG_PATH env # needed for bindgen in mozangle @@ -91,24 +88,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.10' - - name: Install taplo - uses: baptiste0928/cargo-install@v3 - with: - crate: taplo-cli - locked: true - - name: Install cargo-deny - uses: baptiste0928/cargo-install@v3 - with: - crate: cargo-deny - locked: true + - name: Install crown + run: cargo install --path support/crown - name: Bootstrap Python run: python3 -m pip install --upgrade pip - name: Bootstrap dependencies run: | sudo apt update - python3 ./mach bootstrap - - name: Tidy - run: python3 ./mach test-tidy --no-progress --all + python3 ./mach bootstrap --skip-lints - name: Build (${{ inputs.profile }}) run: | python3 ./mach build --use-crown --locked --${{ inputs.profile }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 270bd248a1e..3267ebf5acc 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -79,20 +79,12 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.4 - - name: Install taplo - uses: baptiste0928/cargo-install@v3 - with: - crate: taplo-cli - locked: true - - name: Install cargo-deny - uses: baptiste0928/cargo-install@v3 - with: - crate: cargo-deny - locked: true + - name: Install crown + run: cargo install --path support/crown - name: Bootstrap run: | python3 -m pip install --upgrade pip - python3 ./mach bootstrap + python3 ./mach bootstrap --skip-lints brew install gnu-tar - name: Build (${{ inputs.profile }}) run: | diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 84073d1c3a8..446d4f36ef3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,6 +38,11 @@ jobs: wpt-layout: ${{ github.event_name == 'pull_request' && 'none' || '2020' }} secrets: inherit + lint: + name: Lint + uses: ./.github/workflows/lint.yml + secrets: inherit + build-android: name: Android if: ${{ github.event_name != 'pull_request' }} @@ -64,6 +69,7 @@ jobs: - "build-linux" - "build-android" - "build-ohos" + - "lint" steps: - name: Merge build timings uses: actions/upload-artifact/merge@v4 diff --git a/.github/workflows/ohos.yml b/.github/workflows/ohos.yml index 21e9e6372ba..61400a33c0f 100644 --- a/.github/workflows/ohos.yml +++ b/.github/workflows/ohos.yml @@ -44,20 +44,12 @@ jobs: fetch-depth: 2 - name: Run sccache-cache uses: mozilla-actions/sccache-action@v0.0.4 - - name: Install taplo - uses: baptiste0928/cargo-install@v3 - with: - crate: taplo-cli - locked: true - - name: Install cargo-deny - uses: baptiste0928/cargo-install@v3 - with: - crate: cargo-deny - locked: true + - name: Install crown + run: cargo install --path support/crown - name: Bootstrap Python run: python3 -m pip install --upgrade pip virtualenv - name: Bootstrap dependencies - run: sudo apt update && python3 ./mach bootstrap + run: sudo apt update && python3 ./mach bootstrap --skip-lints - name: Setup OpenHarmony SDK id: setup_sdk uses: openharmony-rs/setup-ohos-sdk@v0.1 diff --git a/.github/workflows/quick-check.yml b/.github/workflows/quick-check.yml deleted file mode 100644 index 6b2c03918fc..00000000000 --- a/.github/workflows/quick-check.yml +++ /dev/null @@ -1,16 +0,0 @@ -# This action is meant as a quick check to be run when pushing to -# branches on forks. This allows forks to test the build and unit -# tests automatically without opening a pull request. -name: Quick check -on: - push: - branches-ignore: - ["main", "auto", "try", "try-*", "dependabot/**"] - -jobs: - build-linux: - name: Linux - if: github.repository != 'servo/servo' || github.event_name == 'workflow_dispatch' - uses: ./.github/workflows/linux.yml - with: - unit-tests: true diff --git a/.github/workflows/try.yml b/.github/workflows/try.yml index 052e57839a2..8e1879dfc7b 100644 --- a/.github/workflows/try.yml +++ b/.github/workflows/try.yml @@ -113,6 +113,7 @@ jobs: needs: [ "decision", "build" ] steps: - name: Merge build timings + continue-on-error: true uses: actions/upload-artifact/merge@v4 with: name: cargo-timings diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 9d63b9d0901..70f32b7fae7 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -64,16 +64,8 @@ jobs: run: choco upgrade llvm - name: ccache uses: hendrikmuhs/ccache-action@v1.2 - - name: Install taplo - uses: baptiste0928/cargo-install@v3 - with: - crate: taplo-cli - locked: true - - name: Install cargo-deny - uses: baptiste0928/cargo-install@v3 - with: - crate: cargo-deny - locked: true + - name: Install crown + run: cargo install --path support/crown - name: Install wixtoolset run: | choco install wixtoolset @@ -86,7 +78,6 @@ jobs: python -m pip install --upgrade pip python mach fetch python mach bootstrap-gstreamer - cargo install --path support/crown # For some reason WiX isn't currently on the GitHub runner path. This is a # temporary workaround until that is fixed. - name: Add WiX to Path diff --git a/python/servo/try_parser.py b/python/servo/try_parser.py index cd19da48d3a..750e0c74424 100644 --- a/python/servo/try_parser.py +++ b/python/servo/try_parser.py @@ -47,6 +47,7 @@ class Workflow(str, Enum): WINDOWS = "windows" ANDROID = "android" OHOS = "ohos" + LINT = "lint" @dataclass @@ -104,6 +105,8 @@ def handle_preset(s: str) -> Optional[JobConfig]: wpt_args="--processes 1 _webgpu", # run only webgpu cts profile="production", # WebGPU works to slow with debug assert unit_tests=False) # production profile does not work with unit-tests + elif s in ["lint", "tidy"]: + return JobConfig("Lint", Workflow.LINT) else: return None @@ -138,7 +141,7 @@ class Config(object): self.fail_fast = True continue # skip over keyword if word == "full": - words.extend(["linux-wpt", "macos", "windows", "android", "ohos"]) + words.extend(["linux-wpt", "macos", "windows", "android", "ohos", "lint"]) continue # skip over keyword job = handle_preset(word) @@ -222,7 +225,14 @@ class TestParser(unittest.TestCase): "profile": "release", "unit_tests": False, "wpt_args": "" - } + }, + { + "name": "Lint", + "workflow": "lint", + "wpt_layout": "none", + "profile": "release", + "unit_tests": False, + "wpt_args": ""} ]}) def test_job_merging(self): @@ -259,7 +269,7 @@ class TestParser(unittest.TestCase): self.assertEqual(a, JobConfig("Linux", Workflow.LINUX, unit_tests=True)) def test_full(self): - self.assertDictEqual(json.loads(Config("linux-wpt macos windows android ohos").to_json()), + self.assertDictEqual(json.loads(Config("linux-wpt macos windows android ohos lint").to_json()), json.loads(Config("").to_json())) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index f564f1958d4..9542e0d8103 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -3,6 +3,7 @@ channel = "1.80.1" components = [ + "clippy", # For support/crown "llvm-tools", # For support/crown