From 2e9b6911d98e8189d77cf791aa743c81fcd76534 Mon Sep 17 00:00:00 2001
From: jayrovacsek
Date: Tue, 5 Nov 2024 20:40:55 +1100
Subject: [PATCH 1/2] feat: add nix based checks
---
.envrc | 1 +
.github/workflows/checks.yml | 12 +++
.gitignore | 1 +
flake.lock | 184 +++++++++++++++++++++++++++++++++++
flake.nix | 112 +++++++++++++++++++++
5 files changed, 310 insertions(+)
create mode 100644 .envrc
create mode 100644 .github/workflows/checks.yml
create mode 100644 flake.lock
create mode 100644 flake.nix
diff --git a/.envrc b/.envrc
new file mode 100644
index 00000000..8392d159
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
\ No newline at end of file
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
new file mode 100644
index 00000000..f66d34bd
--- /dev/null
+++ b/.github/workflows/checks.yml
@@ -0,0 +1,12 @@
+name: checks
+
+on:
+ push:
+
+jobs:
+ checks:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: DeterminateSystems/nix-installer-action@main
+ - run: nix flake check -Lv
diff --git a/.gitignore b/.gitignore
index 67241276..10ebc9cb 100755
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ yarn.lock
/playwright-report/
/blob-report/
/playwright/.cache/
+result
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 00000000..6e1a6614
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,184 @@
+{
+ "nodes": {
+ "devshell": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ },
+ "locked": {
+ "lastModified": 1728330715,
+ "narHash": "sha256-xRJ2nPOXb//u1jaBnDP56M7v5ldavjbtR6lfGqSvcKg=",
+ "owner": "numtide",
+ "repo": "devshell",
+ "rev": "dd6b80932022cea34a019e2bb32f6fa9e494dfef",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "devshell",
+ "type": "github"
+ }
+ },
+ "flake-compat": {
+ "flake": false,
+ "locked": {
+ "lastModified": 1696426674,
+ "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+ "type": "github"
+ },
+ "original": {
+ "owner": "edolstra",
+ "repo": "flake-compat",
+ "type": "github"
+ }
+ },
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1726560853,
+ "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "git-hooks": {
+ "inputs": {
+ "flake-compat": "flake-compat",
+ "gitignore": "gitignore",
+ "nixpkgs": ["nixpkgs"],
+ "nixpkgs-stable": "nixpkgs-stable"
+ },
+ "locked": {
+ "lastModified": 1730797577,
+ "narHash": "sha256-SrID5yVpyUfknUTGWgYkTyvdr9J1LxUym4om3SVGPkg=",
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "rev": "1864030ed24a2b8b4e4d386a5eeaf0c5369e50a9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "cachix",
+ "repo": "git-hooks.nix",
+ "type": "github"
+ }
+ },
+ "gitignore": {
+ "inputs": {
+ "nixpkgs": ["git-hooks", "nixpkgs"]
+ },
+ "locked": {
+ "lastModified": 1709087332,
+ "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
+ "type": "github"
+ },
+ "original": {
+ "owner": "hercules-ci",
+ "repo": "gitignore.nix",
+ "type": "github"
+ }
+ },
+ "nix-filter": {
+ "locked": {
+ "lastModified": 1730207686,
+ "narHash": "sha256-SCHiL+1f7q9TAnxpasriP6fMarWE5H43t25F5/9e28I=",
+ "owner": "numtide",
+ "repo": "nix-filter",
+ "rev": "776e68c1d014c3adde193a18db9d738458cd2ba4",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "nix-filter",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1722073938,
+ "narHash": "sha256-OpX0StkL8vpXyWOGUD6G+MA26wAXK6SpT94kLJXo6B4=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "e36e9f57337d0ff0cf77aceb58af4c805472bfae",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs-stable": {
+ "locked": {
+ "lastModified": 1720386169,
+ "narHash": "sha256-NGKVY4PjzwAa4upkGtAMz1npHGoRzWotlSnVlqI40mo=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "194846768975b7ad2c4988bdb82572c00222c0d7",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-24.05",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "nixpkgs_2": {
+ "locked": {
+ "lastModified": 1730768919,
+ "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "devshell": "devshell",
+ "flake-utils": "flake-utils",
+ "git-hooks": "git-hooks",
+ "nix-filter": "nix-filter",
+ "nixpkgs": "nixpkgs_2"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 00000000..d5a6d1d6
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,112 @@
+{
+ description = "Nodejs Dev Shell";
+
+ inputs = {
+ devshell.url = "github:numtide/devshell";
+ flake-utils.url = "github:numtide/flake-utils";
+ git-hooks = {
+ inputs.nixpkgs.follows = "nixpkgs";
+ url = "github:cachix/git-hooks.nix";
+ };
+ nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
+
+ nix-filter.url = "github:numtide/nix-filter";
+ };
+
+ outputs =
+ {
+ devshell,
+ flake-utils,
+ git-hooks,
+ nixpkgs,
+ nix-filter,
+ self,
+ ...
+ }:
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ app-source = nix-filter.lib.filter {
+ root = ./.;
+ exclude = [ ];
+
+ include = [
+ "src"
+ (nix-filter.lib.matchExt "js")
+ (nix-filter.lib.matchExt "json")
+ (nix-filter.lib.matchExt "ts")
+ ];
+ };
+
+ pkg-lock = builtins.fromJSON (builtins.readFile ./package.json);
+
+ pkgs = import nixpkgs {
+ overlays = [ devshell.overlays.default ];
+ inherit system;
+ };
+ in
+ {
+ checks.git-hooks = git-hooks.lib.${system}.run {
+ src = self;
+ hooks = {
+ actionlint.enable = true;
+
+ deadnix = {
+ enable = true;
+ settings.edit = true;
+ };
+
+ nixfmt-rfc-style.enable = true;
+
+ prettier = {
+ enable = true;
+ settings.write = true;
+ };
+
+ statix.enable = true;
+
+ statix-write = {
+ enable = true;
+ name = "Statix Write";
+ entry = "${pkgs.statix}/bin/statix fix";
+ language = "system";
+ pass_filenames = false;
+ };
+
+ trufflehog-verified = {
+ enable = pkgs.stdenv.isLinux;
+ name = "Trufflehog Search";
+ entry = "${pkgs.trufflehog}/bin/trufflehog git file://. --since-commit HEAD --only-verified --fail --no-update";
+ language = "system";
+ pass_filenames = false;
+ };
+ };
+ };
+
+ devShells.default = pkgs.devshell.mkShell {
+ devshell.startup.git-hooks.text = self.checks.${system}.git-hooks.shellHook;
+ name = "dev-shell";
+ packages = with pkgs; [
+ deadnix
+ nixfmt-rfc-style
+ nodejs_20
+ nodePackages.prettier
+ nodePackages.typescript
+ statix
+ ];
+ };
+
+ formatter = pkgs.nixfmt-rfc-style;
+
+ packages = {
+ newwwie = pkgs.buildNpmPackage {
+ inherit (pkg-lock) version;
+ pname = "newwwie";
+ src = app-source;
+ npmDepsHash = "sha256-FGQpZmR5uSh3kLYyRPLG4KlQnnOzUxnJKeVkCVMabZM=";
+ };
+ };
+ }
+ );
+
+}
From 0cd1390f9ba87edd84be47c0ae94b7b448e14966 Mon Sep 17 00:00:00 2001
From: jayrovacsek
Date: Tue, 5 Nov 2024 20:44:42 +1100
Subject: [PATCH 2/2] fix: resolve check failures
---
.github/workflows/playwright.yml | 36 ++++++++++++++++----------------
package.json | 2 +-
playwright.config.ts | 16 +++++++-------
src/js/events/Meetup.tsx | 11 +++++-----
tests/website.spec.ts | 6 +++---
webpack.config.js | 5 ++---
6 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml
index 3eb13143..cf840d9c 100644
--- a/.github/workflows/playwright.yml
+++ b/.github/workflows/playwright.yml
@@ -1,27 +1,27 @@
name: Playwright Tests
on:
push:
- branches: [ main, master ]
+ branches: [main]
pull_request:
- branches: [ main, master ]
+ branches: [main]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
- - uses: actions/setup-node@v4
- with:
- node-version: lts/*
- - name: Install dependencies
- run: npm ci
- - name: Install Playwright Browsers
- run: npx playwright install --with-deps
- - name: Run Playwright tests
- run: npx playwright test
- - uses: actions/upload-artifact@v4
- if: ${{ !cancelled() }}
- with:
- name: playwright-report
- path: playwright-report/
- retention-days: 30
+ - uses: actions/checkout@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: lts/*
+ - name: Install dependencies
+ run: npm ci
+ - name: Install Playwright Browsers
+ run: npx playwright install --with-deps
+ - name: Run Playwright tests
+ run: npx playwright test
+ - uses: actions/upload-artifact@v4
+ if: ${{ !cancelled() }}
+ with:
+ name: playwright-report
+ path: playwright-report/
+ retention-days: 30
diff --git a/package.json b/package.json
index e23b4688..92ec2a35 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
"fetchEvents": "ts-node ./fetch-events/fetch-events.ts",
"format": "prettier --write .",
"typecheck": "tsc",
- "test":"npx playwright test"
+ "test": "npx playwright test"
},
"repository": {
"type": "git",
diff --git a/playwright.config.ts b/playwright.config.ts
index e7c6e3f5..3267d3ec 100644
--- a/playwright.config.ts
+++ b/playwright.config.ts
@@ -1,4 +1,4 @@
-import { defineConfig, devices } from '@playwright/test';
+import { defineConfig, devices } from "@playwright/test";
/**
* Read environment variables from file.
@@ -12,7 +12,7 @@ import { defineConfig, devices } from '@playwright/test';
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
- testDir: './tests',
+ testDir: "./tests",
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
@@ -22,21 +22,21 @@ export default defineConfig({
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
- reporter: 'html',
+ reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
- trace: 'on-first-retry',
+ trace: "on-first-retry",
},
/* Configure projects for major browsers */
projects: [
{
- name: 'chromium',
- use: { ...devices['Desktop Chrome'] },
+ name: "chromium",
+ use: { ...devices["Desktop Chrome"] },
},
// {
@@ -72,8 +72,8 @@ export default defineConfig({
/* Run your local dev server before starting the tests */
webServer: {
- command: 'npm run dev',
- url: 'http://127.0.0.1:9000',
+ command: "npm run dev",
+ url: "http://127.0.0.1:9000",
reuseExistingServer: !process.env.CI,
},
});
diff --git a/src/js/events/Meetup.tsx b/src/js/events/Meetup.tsx
index 4bf66cbd..2ea38941 100644
--- a/src/js/events/Meetup.tsx
+++ b/src/js/events/Meetup.tsx
@@ -9,8 +9,8 @@ import { events } from "./events-data";
*/
// @ts-ignore
const eventIdNode: HTMLElement = document.getElementById("meetupEvents");
-import showdown from "showdown"
-import DOMPurify from 'dompurify';
+import showdown from "showdown";
+import DOMPurify from "dompurify";
export class Meetup extends Component {
/**
@@ -39,7 +39,7 @@ export class Meetup extends Component {
const prettyTime = this.niceTime(startTime);
const converter = new showdown.Converter();
let formattedEventDescription = converter.makeHtml(event.description.substring(0, 240)).toString();
- formattedEventDescription = formattedEventDescription.replace(/<\/?p>/g, '');
+ formattedEventDescription = formattedEventDescription.replace(/<\/?p>/g, "");
return (
@@ -60,8 +60,9 @@ export class Meetup extends Component {
Hosted by: {group.name}
-
-
diff --git a/tests/website.spec.ts b/tests/website.spec.ts
index d15cb1a1..f721c69f 100644
--- a/tests/website.spec.ts
+++ b/tests/website.spec.ts
@@ -1,7 +1,7 @@
-import { test, expect } from '@playwright/test';
+import { test, expect } from "@playwright/test";
-test('has title', async ({ page }) => {
- await page.goto('localhost:9000');
+test("has title", async ({ page }) => {
+ await page.goto("localhost:9000");
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle("Newie | an open community of digital creators in newcastle nsw.");
diff --git a/webpack.config.js b/webpack.config.js
index 30f0f14f..0daa6e10 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -5,8 +5,7 @@ const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
-const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
-
+const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
module.exports = {
mode: "production",
@@ -22,7 +21,7 @@ module.exports = {
new CssMinimizerPlugin(),
],
splitChunks: {
- chunks: 'all',
+ chunks: "all",
minSize: 20000,
maxSize: 244000, // Adjust this limit based on your target size
},