Skip to content

Commit

Permalink
Fix build (#54)
Browse files Browse the repository at this point in the history
* Simplify build

* Do install

* Use npx

* Build and setup

* Remove version

* Cache dependencies

* Setup node

* Try to fix build test
  • Loading branch information
anxolin authored Feb 15, 2024
1 parent af9ed21 commit 2498710
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 43 deletions.
38 changes: 14 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,32 @@ on:
- main
# Launches build when release is published
release:
types: [ published ]
types: [published]

jobs:
build:
name: Build Package
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Remove broken apt repos [Ubuntu]
if: ${{ matrix.os }} == 'ubuntu-latest'
run: |
for apt_file in `grep -lr microsoft /etc/apt/sources.list.d/`; do sudo rm $apt_file; done
- uses: actions/checkout@v3

- name: Setup Node.js
- name: Set up Node.js
uses: actions/setup-node@v3

- uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
node-version: 14

- run: |
# Due to some dependencies yarn may randomly throw an error about invalid cache
# This approach is taken from https://github.com/yarnpkg/yarn/issues/7212#issuecomment-506155894 to fix the issue
# Another approach is to install with flag --network-concurrency 1, but this will make the installation pretty slow (default value is 8)
mkdir .yarncache
yarn install --cache-folder ./.yarncache --frozen-lockfile
rm -rf .yarncache
yarn cache clean
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: |
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install

- name: Build app
run: yarn build
31 changes: 13 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
name: Unit tests
on: [ push, pull_request ]
on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Setup Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Yarn cache
- name: Cache Yarn dependencies
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
path: |
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Yarn install
run: |
mkdir .yarncache
yarn install --cache-folder ./.yarncache --frozen-lockfile
rm -rf .yarncache
yarn cache clean
- name: Install dependencies
run: yarn install

- name: Run tests
run: yarn test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"scripts": {
"clean": "rm -rf dist/* && rm -rf src/generatedTypes/* && rm -rf schemas/",
"compile": "ts-node --esm src/scripts/compile.ts --experimental-specifier-resolution=node",
"compile": "npx ts-node --esm src/scripts/compile.ts --experimental-specifier-resolution=node",
"build": "yarn clean && yarn compile && microbundle -f modern,esm,cjs",
"test": "jest",
"prepare": "yarn build && yarn test"
Expand Down

0 comments on commit 2498710

Please sign in to comment.