From 277bf1ef4cc3165c782bd6726c1c60766fae2fe5 Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Wed, 1 May 2024 15:13:24 -0400 Subject: [PATCH] feat: add CodSpeed to the project --- .github/workflows/benchmark.yml | 33 +++++++++++++++++++++++ .github/workflows/hlint.yml | 46 --------------------------------- .github/workflows/lint.yml | 31 ---------------------- v3/Cargo.lock | 40 +++++++++++++++++++++++++--- v3/Cargo.toml | 2 +- 5 files changed, 71 insertions(+), 81 deletions(-) create mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/hlint.yml delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 00000000000000..baa5dd85583110 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,33 @@ +name: codspeed-benchmarks + +on: + # Run on pushes to the master branch + push: + branches: + - "master" + # Run on pull requests + pull_request: + # `workflow_dispatch` allows CodSpeed to trigger backtest + # performance analysis in order to generate initial data. + workflow_dispatch: + +jobs: + benchmarks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup rust toolchain, cache and cargo-codspeed binary + uses: moonrepo/setup-rust@v1 + with: + cache-target: release + bins: cargo-codspeed + + - name: Build the benchmark target(s) + working-directory: v3 + run: cargo codspeed build -p engine -p lang-graphql + + - name: Run the benchmarks + uses: CodSpeedHQ/action@v2 + with: + working-directory: v3 + run: cargo codspeed run -p engine -p lang-graphql diff --git a/.github/workflows/hlint.yml b/.github/workflows/hlint.yml deleted file mode 100644 index 066048b806bbd3..00000000000000 --- a/.github/workflows/hlint.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: server lint -on: - label: - pull_request: - paths: - - "server/**" - -jobs: - hlint: - runs-on: ubuntu-20.04 - if: "!contains(github.event.pull_request.labels.*.name, 'ignore-server-hlint-checks') && github.event.label.name != 'ignore-server-hlint-checks'" - env: - working-directory: . - HLINT_BASE_URL: https://github.com/ndmitchell/hlint/releases/download - HLINT_ARCH: x86_64 - HLINT_OS: linux - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Download hlint - run: | - HLINT_VERSION="$(jq -r '.hlint' ./server/VERSIONS.json)" - HLINT_URL="${{env.HLINT_BASE_URL}}/v${HLINT_VERSION}/hlint-${HLINT_VERSION}-${{env.HLINT_ARCH}}-${{env.HLINT_OS}}.tar.gz" - echo "Downloading from ${HLINT_URL}" - curl --fail --location --output "./hlint.tar.gz" "${HLINT_URL}" - tar xvf \ - hlint.tar.gz \ - --directory='.' \ - --strip-components=1 \ - "hlint-${HLINT_VERSION}/hlint" - - - name: Run hlint - shell: bash - run: | - CHANGED_HS_FILES=$(git diff --name-only origin/${{github.base_ref}}...${{github.sha}} -- "./*.hs" | xargs -i -d '\n' sh -c 'ls -d {} 2>/dev/null || true') - echo "$CHANGED_HS_FILES" - JQ_SCRIPT='.[] | "::" + (if (.severity=="Warning" or .severity=="Error") then "error" else "warning" end) + " file=\(.file),line=\(.startLine),col=\(.startColumn)::\(.severity):" + " \(.hint)%0AFound:%0A \(.from | gsub("\n";"%0A "))%0A" + try ("Perhaps:%0A " + (.to | gsub("\n";"%0A ")) + "%0A") catch "" + try (if .note | length > 0 then "Note:%0A " + (.note | join("\n") | gsub("\n";"%0A ")) else "" end) catch ""' - if [[ "$CHANGED_HS_FILES" ]] - then - OUT=$(mktemp) - echo "$CHANGED_HS_FILES" | xargs ${{env.working-directory}}/hlint --no-exit-code --json --hint=./.hlint.yaml | jq -r "$JQ_SCRIPT" | tee $OUT - test -z "$(grep -E '^::error' $OUT)" - fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 384deb8d429d79..00000000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: console lint -on: - pull_request: - paths: - - 'console/**' - -jobs: - lint: - runs-on: ubuntu-latest - env: - working-directory: ./console - - steps: - - uses: actions/checkout@v2 - - - name: Use Node.js 12 - uses: actions/setup-node@v1 - with: - node-version: 12.x - - - name: Install - working-directory: ${{env.working-directory}} - run: npm ci - - - name: Lint - working-directory: ${{env.working-directory}} - run: npm run lint:quiet - - - name: Format - working-directory: ${{env.working-directory}} - run: npm run format:check diff --git a/v3/Cargo.lock b/v3/Cargo.lock index f4d4c4ad79e8c1..49f3fa9c64b09d 100644 --- a/v3/Cargo.lock +++ b/v3/Cargo.lock @@ -908,12 +908,46 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" +[[package]] +name = "codspeed" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a104ac948e0188b921eb3fcbdd55dcf62e542df4c7ab7e660623f6288302089" +dependencies = [ + "colored", + "libc", + "serde_json", +] + +[[package]] +name = "codspeed-criterion-compat" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "722c36bdc62d9436d027256ce2627af81ac7a596dfc7d13d849d0d212448d7fe" +dependencies = [ + "codspeed", + "colored", + "criterion", + "futures", + "tokio", +] + [[package]] name = "colorchoice" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "combine" version = "3.8.1" @@ -1717,7 +1751,7 @@ dependencies = [ "base64 0.22.1", "build-data", "clap", - "criterion", + "codspeed-criterion-compat", "execute", "goldenfile", "hasura-authn-core", @@ -1793,7 +1827,7 @@ dependencies = [ "axum", "base64 0.22.1", "bytes", - "criterion", + "codspeed-criterion-compat", "derive_more", "futures-ext", "futures-util", @@ -2606,7 +2640,7 @@ dependencies = [ "axum", "bincode", "bson", - "criterion", + "codspeed-criterion-compat", "diffy", "expect-test", "graphql-parser", diff --git a/v3/Cargo.toml b/v3/Cargo.toml index 23c5d1209d65ac..76a1f4ce8242a2 100644 --- a/v3/Cargo.toml +++ b/v3/Cargo.toml @@ -70,7 +70,7 @@ bytes = "1" clap = "4" convert_case = "0.6" cookie = "0.18" -criterion = "0.5" +criterion = { package="codspeed-criterion-compat", version = "2.6.0" } darling = "0.20" derive_more = "0.99" diffy = "0.4"