Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests, linting and GitHub workflow #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
30 changes: 30 additions & 0 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Reboot.dev Node.js Template

on: [push]

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Lint sources
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'
- run: npm ci
- run: npm run lint

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run all tests
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'
- run: npm ci
- run: npm run test
4 changes: 2 additions & 2 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Application } from "@reboot-dev/reboot";
import { Application, ExternalContext } from "@reboot-dev/reboot";

const initialize = async (context) => {};
const initialize = async (context: ExternalContext) => {};

Check failure on line 3 in backend/src/main.ts

View workflow job for this annotation

GitHub Actions / Lint

'context' is defined but never used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context is unused.

Copy link
Author

@aldipower aldipower Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this can stay as it is and acts as a good entry point for this template, imho. :-)
"Lint fails intentionally" :-)

Copy link
Contributor

@rileysdev rileysdev Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure how I feel about shipping an example with unused args that fails to pass lint check. If you want to keep this as-is, I'd suggest turning off linting for this line only with a comment explaining why.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this were an example, I would absolutely see it as you do.
As this is a template and not an example I personally have no problems with failing lint checks. Turning the linting off for this line is not a good idea I guess. If the templates gets filled with live, this switch could stay on accidentally.


new Application({
servicers: [],
Expand Down
25 changes: 25 additions & 0 deletions backend/tests/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ExternalContext, Reboot } from "@reboot-dev/reboot";
import { describe, it, before, after } from "node:test";
import assert from "node:assert";

describe("Main Application", async () => {
let context: ExternalContext;
let rbt: Reboot;

before(async () => {
rbt = new Reboot();
await rbt.start();
await rbt.up([]);
context = rbt.createExternalContext("test-runner");
});

after(async () => {
await rbt.stop();
});

describe("Servicer", () => {
it("does not throw", async () => {
assert.ok(context);
});
});
});
9 changes: 9 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
);
Loading
Loading