Skip to content

Commit

Permalink
Merge pull request #4 from TomAFrench/tf/add-ci
Browse files Browse the repository at this point in the history
chore: add CI
  • Loading branch information
TomAFrench committed Apr 23, 2024
2 parents df05f34 + 74454cb commit 017a479
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 11 deletions.
16 changes: 16 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 8 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);

Check failure on line 116 in src/index.ts

View workflow job for this annotation

GitHub Actions / check-dist

Argument of type 'ProgramReport[]' is not assignable to parameter of type 'CircuitReport[]'.
core.info(`Format markdown of ${diffRows.length} diffs`);
const markdown = formatMarkdownDiff(
header,
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 017a479

Please sign in to comment.