hyperledger-cacti / cacti

Hyperledger Cacti is a new approach to the blockchain interoperability problem
https://wiki.hyperledger.org/display/cactus
Apache License 2.0
339 stars 283 forks source link

ci(github): add check to validate exported types being correct #3140

Open petermetz opened 6 months ago

petermetz commented 6 months ago

Description

As a maintainer/reviewer I want to have automation that checks if our exports are correct for both CJS/ESM so that we are less likely to accidentally merge something that would make the exports mess up and cause import issues for the downstream libraries/applications.

https://www.npmjs.com/package/@arethetypeswrong/cli

Acceptance Criteria

  1. Does not duplicate the entire build process needlessly.
  2. Evaluate if we should do it for every commit or just prior to release issuance.
  3. Be mindful of CI resources consumed by this in general.
petermetz commented 1 month ago

@ruzell22

yarn lerna exec 'npm pack'
$ attw ./packages/cactus-plugin-ledger-connector-besu/hyperledger-cactus-plugin-ledger-connector-besu-2.0.0-rc.3.tgz 

@hyperledger/cactus-plugin-ledger-connector-besu v2.0.0-rc.3

 No problems found 🌟

┌───────────────────┬────────────────────────────────────────────────────┐
│                   │ "@hyperledger/cactus-plugin-ledger-connector-besu" │
├───────────────────┼────────────────────────────────────────────────────┤
│ node10            │ 🟢                                                 │
├───────────────────┼────────────────────────────────────────────────────┤
│ node16 (from CJS) │ 🟢 (CJS)                                           │
├───────────────────┼────────────────────────────────────────────────────┤
│ node16 (from ESM) │ 🟢 (CJS)                                           │
├───────────────────┼────────────────────────────────────────────────────┤
│ bundler           │ 🟢                                                 │
└───────────────────┴────────────────────────────────────────────────────┘
petermetz commented 1 month ago

@ruzell22

  1. The above example works for a single .tgz file
  2. You can write a globby pattern in one of the nodejs tooling scripts (the ones that are within the custom-checks area)
  3. Capture a list of the file paths for all the *.tgz files and then run a shell command for each individually
petermetz commented 1 month ago

https://github.com/arethetypeswrong/arethetypeswrong.github.io/tree/main/packages/core

@ruzell22 If possible use the library not the CLI (which would force you to run shell commands from the NodeJS script)