From 74798c6e613d887ac39dafacbbe6ee0b04bc30d4 Mon Sep 17 00:00:00 2001 From: Marton Lederer Date: Sat, 20 Feb 2021 11:29:47 +0100 Subject: [PATCH] feat: workflows --- .github/workflows/fmt.yml | 21 +++++++++++++++++++++ .github/workflows/test.yml | 21 +++++++++++++++++++++ build.js | 16 +++++++++------- package.json | 2 +- 4 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/fmt.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml new file mode 100644 index 0000000..7813658 --- /dev/null +++ b/.github/workflows/fmt.yml @@ -0,0 +1,21 @@ +name: fmt + +on: [push, pull_request] + +jobs: + fmt: + name: Check code formatting + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + + - name: Install yarn + run: npm i -g yarn + + - name: Install dependencies + run: yarn + + - name: Check fmt + run: yarn fmt:check \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8c50624 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,21 @@ +name: Test + +on: [push, pull_request] + +jobs: + fmt: + name: Test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-node@v1 + + - name: Install yarn + run: npm i -g yarn + + - name: Install dependencies + run: yarn + + - name: Run tests + run: yarn test \ No newline at end of file diff --git a/build.js b/build.js index d9fa8ac..45dc869 100644 --- a/build.js +++ b/build.js @@ -8,10 +8,12 @@ build({ watch: !production, format: "cjs", outfile: `./dist/index.js` -}).catch(() => process.exit(1)); - -// copy module declarations -copyFile("./src/modules.d.ts", "./dist/modules.d.ts", (err) => { - if (err) throw err; - console.log("[modules.d.ts] copied"); -}); +}) + .then(() => { + // copy module declarations + copyFile("./src/modules.d.ts", "./dist/modules.d.ts", (err) => { + if (err) throw err; + console.log("[modules.d.ts] copied"); + }); + }) + .catch(() => process.exit(1)); diff --git a/package.json b/package.json index 52785d3..6836106 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "NODE_ENV=production node build.js && tsc --emitDeclarationOnly", "dev": "NODE_ENV=development node build.js", - "test": "cd test && mocha 'index.js' --no-timeout --exit", + "test": "yarn build && cd test && mocha 'index.js' --no-timeout --exit", "fmt": "prettier --write .", "fmt:check": "prettier --check ." },