From 7fa9987b46f78a42daadddd902e4425065998f07 Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Tue, 28 Jun 2022 13:23:45 +0200 Subject: [PATCH] chore: CI stuff --- .github/FUNDING.yml | 12 +++++ .github/workflows/test-and-release.yml | 72 ++++++++++++++++++++++++++ package.json | 5 +- src/server.ts | 2 +- tsconfig.json | 1 + 5 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/workflows/test-and-release.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..c3550b1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: [zwave-js] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: z-wave-js # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..9aff2f2 --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,72 @@ +name: Test and Release + +# Run this job on all pushes to main and for pull requests +on: + push: + branches: + # This avoids having duplicate builds in non-forked PRs + - "main" + pull_request: {} + +# Cancel previous PR/branch runs when a new commit is pushed +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + # =================== + # Catches style errors + lint: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x] # This should be LTS + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: Install dependencies + run: yarn install --immutable + + - name: Compile TypeScript code + run: yarn build + + - name: Run linter + run: yarn run lint + + # =================== + # Runs unit tests + unit-tests: + if: contains(github.event.head_commit.message, '[skip ci]') == false + + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [16.x] # This should be LTS + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + + - name: Install dependencies + run: yarn install --immutable + + # Compilation is necessary, or the tests won't run + - name: Compile TypeScript code + run: yarn run build + + - name: Run component tests + run: yarn run test:ci diff --git a/package.json b/package.json index 7a89235..e11ae4a 100644 --- a/package.json +++ b/package.json @@ -7,12 +7,13 @@ "author": "Dominic Griesel ", "license": "MIT", "scripts": { - "build": "tsc --verbose", + "build": "tsc", "clean": "tsc --clean", "watch": "yarn run build --watch --pretty", "lint": "eslint .", "dev": "nodemon src/server.ts", - "start": "node build/server.js" + "start": "node build/server.js", + "test:ci": "exit 0" }, "devDependencies": { "@tsconfig/node16": "^1.0.3", diff --git a/src/server.ts b/src/server.ts index 4de2ce7..3eb94e9 100644 --- a/src/server.ts +++ b/src/server.ts @@ -3,7 +3,7 @@ import fastifyLib from "fastify"; const fastify = fastifyLib({ logger: true }); // Declare a route -fastify.get("/", async (request, reply) => { +fastify.get("/", async (_request, _reply) => { return { hello: "world!" }; }); diff --git a/tsconfig.json b/tsconfig.json index 7badeee..b1565a7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "@tsconfig/node16/tsconfig.json", "compilerOptions": { + "outDir": "build", "importsNotUsedAsValues": "error", "pretty": true, },