Files
discordeno/.github/workflows/lib-check.yml
Fleny 27fc12ec34 feat(cli)!: CLI generated types (#3453)
* Move transformers types to a single file

* Add script to test TS Compiler api capabilities
Remove nested objects where possible

* Use Partial<Role> and DiscordOverwrite instead of objects in AuditLogChange

* Fix typescript errors

* Remove interfaces.json

It is a generated file from the test script, not something that should be commited

* Start work on the test generation script
The TS version got bumped to 5.5.3

* Fix any type, use node16 module resolution

"node" is a deprecated alias for "node10", node16 is the recommended

Add code to check for type errors when getting the types from the interfaces

Fix errors when TS tries to find the files that the root tsconfig.json handles

* remove some useless compile options in TSApiTest

* Add jsdoc parsing
JSDoc tags with the next right after are not supported

* fix small format issue

* Fix ApplicationCommandPermissions todo

* Fix CI error

* Simplify parseDocumentation

* get type directly from the sourceFile

* remove hasUndefinedUnion as it is no longer used

* fix discordeno bin file name

* Update the yarn lockfile

* Merge scripts into one

* Use `@internal` instead of `@private` + `@deprecated`

* work on .d.ts files

* Process interface members once

* Move emit/preEmit diagnostics to a unit test

they can take quite a while, even 3-4 seconds, so running in the CLI every time does not seem ideal

* test: add build:types to test:unit dependencies

This is a test commit, it will provably get reversed. The scope is to see what CI does with this

* add find-up to deno import map

* add typescript to the deno import map

* Add node:assert to deno import map

* check for this.timeout that exists

deno does not have the timeout

* add build:type to deno-unit

* Temp hack to work-around the script deno tests

* Test with bun running the test as well

* fix turbo deps for unit tests

* remove test scripts

* Update CI to use build:type cache

* Apply code review suggestion

Co-authored-by: LTS20050703 <lts20050703@gmail.com>

* Add code to modify the interface member

* use an actual config

The config source is still a dummy object for now

* Search and use discordeno.config.js file

* provide config from cli options

* Handle props in base objects
The dependencies of an object need to be declared/updated manually, it would be painful to fix this in such a way that would be something that Typescript can give us from the compiler API

* add some tests for desired proprieties

* also check for a .mjs config file

* Add support for .ts config files

We use the typescript compiler to emit an in-memory version of the config file, import it and then remove it. It does not do bundling so if the config imports local files it will not work. Also the file is not type-checked as it would slow down the config loading

* remove compiler host, use callback on program.emit

* fix deno ci error

* add node:fs/promises to deno import map

---------

Co-authored-by: LTS20050703 <lts20050703@gmail.com>
2024-07-20 16:52:21 -05:00

237 lines
6.8 KiB
YAML

name: Library Checks
on:
pull_request:
push:
branches:
- main
paths-ignore:
- 'website/**'
merge_group:
jobs:
build-type-and-test:
name: Build Type and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --immutable
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
- name: Build Type and Test
run: yarn build:type --cache-dir=".turbo"
build-dist:
name: Build Dist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --immutable
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-build-${{ github.sha }}
- name: Type Test
run: yarn build --cache-dir=".turbo"
format-unit-and-integration-test:
name: Format Test
runs-on: ubuntu-latest
needs: build-type-and-test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --immutable
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-lint-${{ github.sha }}
- name: Build type cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
- name: Check Formatting
run: yarn lint --cache-dir=".turbo"
test-type-unit-and-integration-test:
name: Test Type Test
runs-on: ubuntu-latest
needs: build-type-and-test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn install --immutable
- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-unit-and-integration-test:test-type-${{ github.sha }}
- name: Build type cache
if: steps.turbo-cache.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-build:type-${{ github.sha }}
- name: Test Type Test
run: yarn test:test-type --cache-dir=".turbo"
# Not using matrix because test later on cant needs a specific job
bot-unit-test:
name: Bot
needs: [build-dist, build-type-and-test]
uses: ./.github/workflows/unit-test.yml
with:
package: bot
# https://github.com/orgs/community/discussions/12835
# bot-e2e-test:
# name: Bot
# needs: bot-unit-test
# if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'merge_group' }}
# uses: ./.github/workflows/e2e-test.yml
# secrets: inherit
# with:
# package: bot
bot-other-runtime-test:
name: Bot
needs: bot-unit-test
uses: ./.github/workflows/other-runtime-unit-test.yml
with:
package: bot
discordeno-unit-test:
name: Discordeno
needs: [build-dist, build-type-and-test]
uses: ./.github/workflows/unit-test.yml
with:
package: discordeno
discordeno-other-runtime-test:
name: Discordeno
needs: discordeno-unit-test
uses: ./.github/workflows/other-runtime-unit-test.yml
with:
package: discordeno
gateway-unit-test:
name: Gateway
needs: [build-dist, build-type-and-test]
uses: ./.github/workflows/unit-test.yml
with:
package: gateway
gateway-integration-test:
name: Gateway
needs: build-dist
uses: ./.github/workflows/integration-test.yml
with:
package: gateway
gateway-other-runtime-test:
name: Gateway
needs: [gateway-unit-test, gateway-integration-test]
uses: ./.github/workflows/other-runtime-unit-test.yml
with:
package: gateway
rest-unit-test:
name: Rest
needs: [build-dist, build-type-and-test]
uses: ./.github/workflows/unit-test.yml
with:
package: rest
# https://github.com/orgs/community/discussions/12835
# rest-e2e-test:
# name: Rest
# needs: rest-unit-test
# if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'merge_group' }}
# uses: ./.github/workflows/e2e-test.yml
# secrets: inherit
# with:
# package: rest
rest-other-runtime-test:
name: Rest
needs: rest-unit-test
uses: ./.github/workflows/other-runtime-unit-test.yml
with:
package: rest
types-unit-test:
name: Types
needs: [build-dist, build-type-and-test]
uses: ./.github/workflows/unit-test.yml
with:
package: types
types-other-runtime-test:
name: Types
needs: types-unit-test
uses: ./.github/workflows/other-runtime-unit-test.yml
with:
package: types
utils-unit-test:
name: Utils
needs: [build-dist, build-type-and-test]
uses: ./.github/workflows/unit-test.yml
with:
package: utils
utils-other-runtime-test:
name: Utils
needs: utils-unit-test
uses: ./.github/workflows/other-runtime-unit-test.yml
with:
package: utils