From f6259dffeabb5354708dac9235624a6ba13c5808 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 23 Apr 2024 19:08:33 +0100 Subject: [PATCH 1/2] chore: add CI --- .github/actions/setup/action.yml | 16 ++++++++++++++++ .github/workflows/formatting.yml | 28 ++++++++++++++++++++++++++++ .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .github/actions/setup/action.yml create mode 100644 .github/workflows/formatting.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..d0e83de --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,16 @@ +name: Install Yarn dependencies +description: Installs the workspace's yarn dependencies and caches them + +runs: + using: composite + steps: + - uses: actions/setup-node@v4 + id: node + with: + node-version: 18.19.0 + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + + - name: Install + run: yarn --immutable + shell: bash diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 0000000..4eaf2e6 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,28 @@ +name: Formatting + +on: + pull_request: + push: + branches: + - master + +# This will cancel previous runs when a branch or PR is updated +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + eslint: + name: eslint + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Yarn dependencies + uses: ./.github/actions/setup + + - name: Run `yarn lint` + run: yarn lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..edc9a09 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Tests + +on: + pull_request: + push: + branches: + - master + +# This will cancel previous runs when a branch or PR is updated +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + test: + name: Integration Tests (Node) + runs-on: ubuntu-latest + timeout-minutes: 30 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Yarn dependencies + uses: ./.github/actions/setup + + - name: Run `yarn test` + run: yarn test From 74454cb43bb4b0a3de72a6c9bac43cc157b7be59 Mon Sep 17 00:00:00 2001 From: Tom French Date: Tue, 23 Apr 2024 19:16:45 +0100 Subject: [PATCH 2/2] chore: fix linting --- src/index.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/index.ts b/src/index.ts index 63510fb..72be288 100755 --- a/src/index.ts +++ b/src/index.ts @@ -40,8 +40,8 @@ async function run() { try { // Upload the gates report to be used as a reference in later runs. await uploadArtifact(); - } catch (error: any) { - return core.setFailed(error.message); + } catch (error) { + return core.setFailed((error as Error).message); } // cannot use artifactClient because downloads are limited to uploads in the same workflow run @@ -88,15 +88,15 @@ async function run() { archive_format: "zip", }); - const zip = new Zip(Buffer.from(res.data as any)); + const zip = new Zip(Buffer.from(res.data as ArrayBuffer)); for (const entry of zip.getEntries()) { core.info(`Loading gas reports from "${entry.entryName}"`); referenceContent = zip.readAsText(entry); } core.endGroup(); } else core.error(`No workflow run found with an artifact named "${baseReport}"`); - } catch (error: any) { - return core.setFailed(error.message); + } catch (error) { + return core.setFailed((error as Error).message); } } @@ -113,10 +113,7 @@ async function run() { core.endGroup(); core.startGroup("Compute gas diff"); - const diffRows = computeProgramDiffs( - referenceReports.programs[0].functions, - compareReports.programs[0].functions - ); + const diffRows = computeProgramDiffs(referenceReports.programs, compareReports.programs); core.info(`Format markdown of ${diffRows.length} diffs`); const markdown = formatMarkdownDiff( header, @@ -136,8 +133,8 @@ async function run() { core.setOutput("shell", shell); core.setOutput("markdown", markdown); } - } catch (error: any) { - core.setFailed(error.message); + } catch (error) { + core.setFailed((error as Error).message); } }