Switch type check to GitHub Actions
and add (working) type check for release mode js-sdk types
This commit is contained in:
parent
92ad81ed76
commit
47fd11050f
3 changed files with 42 additions and 21 deletions
25
.github/workflows/lint.yaml
vendored
Normal file
25
.github/workflows/lint.yaml
vendored
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
name: Lint
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [develop]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: c-hive/gha-yarn-cache@v2
|
||||||
|
- name: Install Deps
|
||||||
|
run: "./scripts/ci/install-deps.sh --ignore-scripts"
|
||||||
|
- name: Typecheck
|
||||||
|
run: "yarn run lint:types"
|
||||||
|
- name: Switch js-sdk to release mode
|
||||||
|
run: |
|
||||||
|
scripts/ci/js-sdk-to-release.js
|
||||||
|
pushd node_modules/matrix-js-sdk
|
||||||
|
yarn install
|
||||||
|
yarn run build:compile
|
||||||
|
yarn run build:types
|
||||||
|
popd
|
||||||
|
- name: Typecheck (release mode)
|
||||||
|
run: "yarn run lint:types"
|
||||||
|
|
17
scripts/ci/js-sdk-to-release.js
Executable file
17
scripts/ci/js-sdk-to-release.js
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
const fsProm = require('fs/promises');
|
||||||
|
|
||||||
|
const PKGJSON = 'node_modules/matrix-js-sdk/package.json';
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const pkgJson = JSON.parse(await fsProm.readFile(PKGJSON, 'utf8'));
|
||||||
|
for (const field of ['main', 'typings']) {
|
||||||
|
if (pkgJson["matrix_lib_"+field] !== undefined) {
|
||||||
|
pkgJson[field] = pkgJson["matrix_lib_"+field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await fsProm.writeFile(PKGJSON, JSON.stringify(pkgJson, null, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
|
@ -1,21 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# This changes the js-sdk into 'release mode', that is:
|
|
||||||
# * The entry point for the library is the babel-compiled lib/index.js rather than src/index.ts
|
|
||||||
# * There's a 'typings' entry referencing the types output by tsc
|
|
||||||
# We do this so we can test that each PR still builds / type checks correctly when built
|
|
||||||
# against the released js-sdk, because if you do things like `import { User } from 'matrix-js-sdk';`
|
|
||||||
# rather than `import { User } from 'matrix-js-sdk/src/models/user';` it will work fine with the
|
|
||||||
# js-sdk in development mode but then break at release time.
|
|
||||||
# We can't use the last release of the js-sdk though: it might not be up to date enough.
|
|
||||||
|
|
||||||
cd node_modules/matrix-js-sdk
|
|
||||||
for i in main typings
|
|
||||||
do
|
|
||||||
lib_value=$(jq -r ".matrix_lib_$i" package.json)
|
|
||||||
if [ "$lib_value" != "null" ]; then
|
|
||||||
jq ".$i = .matrix_lib_$i" package.json > package.json.new && mv package.json.new package.json
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
yarn run build:compile
|
|
||||||
yarn run build:types
|
|
Loading…
Add table
Add a link
Reference in a new issue