diff --git a/.github/workflows/test-and-release.yaml b/.github/workflows/test-and-release.yaml index 4b6e685..553a03e 100644 --- a/.github/workflows/test-and-release.yaml +++ b/.github/workflows/test-and-release.yaml @@ -9,10 +9,13 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup bun - uses: oven-sh/setup-bun@v1 + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v26 + - uses: cachix/cachix-action@v14 + with: + name: devenv + - name: Install devenv.sh + run: nix profile install nixpkgs#devenv - name: Get bun cache directory id: bun-cache-dir run: | @@ -25,13 +28,12 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }} restore-keys: | ${{ runner.os }}-node- - - name: Install dependencies - run: | - bun install - name: Check code quality + shell: devenv shell bash -- -e {0} run: | make check-all - name: Compile + shell: devenv shell bash -- -e {0} run: make - name: Upload artifact uses: actions/upload-artifact@v3 @@ -44,10 +46,13 @@ jobs: runs-on: ubuntu-latest if: github.ref_type == 'branch' && github.ref_name == 'master' steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup bun - uses: oven-sh/setup-bun@v1 + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v26 + - uses: cachix/cachix-action@v14 + with: + name: devenv + - name: Install devenv.sh + run: nix profile install nixpkgs#devenv - name: Get bun cache directory id: bun-cache-dir run: | @@ -60,15 +65,13 @@ jobs: key: ${{ runner.os }}-node-${{ hashFiles('**/bun.lockb') }} restore-keys: | ${{ runner.os }}-node- - - name: Install dependencies - run: | - bun install - name: Download artifact uses: actions/download-artifact@v3 with: name: mixxx-launchpad-${{ github.sha }}-${{ github.run_id }} path: dist - name: Create release + shell: devenv shell bash -- -e {0} run: bunx semantic-release env: GITHUB_TOKEN: ${{ github.token }} diff --git a/.gitignore b/.gitignore index eaae6d8..2e7da4e 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,12 @@ jspm_packages .vscode *.iml .idea +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml diff --git a/.lefthook.yml b/.lefthook.yml deleted file mode 100644 index 0e8d8df..0000000 --- a/.lefthook.yml +++ /dev/null @@ -1,12 +0,0 @@ -pre-commit: - parallel: true - commands: - eslint: - glob: '*.{js,ts}' - run: bunx eslint {staged_files} - prettier: - glob: '*.{js,ts,json,md,yml,yaml}' - run: bunx prettier --check {staged_files} - tsc: - glob: '*.{js,ts}' - run: bunx tsc-files --noEmit {staged_files} diff --git a/README.MD b/README.MD index f12be06..a9c7d05 100644 --- a/README.MD +++ b/README.MD @@ -476,8 +476,6 @@ The code should pass CI checks, which is equivalent to running make check-all ``` -We use [lefthook](https://github.com/evilmartians/lefthook) to run precommit hooks. - [babel]: https://babeljs.io/ [rollup]: https://rollupjs.org [standalone]: https://github.com/substack/node-browserify#usage diff --git a/bun.lockb b/bun.lockb index f3f56df..8c07ed2 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..26bfccd --- /dev/null +++ b/devenv.lock @@ -0,0 +1,122 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1725121898, + "owner": "cachix", + "repo": "devenv", + "rev": "3ec083c9d58c9007d2be2a6145b578c67322d575", + "treeHash": "bf1b1c575f1a722f1c69c1ea92fa7ff5a6030bb7", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "treeHash": "2addb7b71a20a25ea74feeaf5c2f6a6b30898ecb", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "treeHash": "ca14199cabdfe1a06a7b1654c76ed49100a689f9", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1716977621, + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "4267e705586473d3e5c8d50299e71503f16a6fb6", + "treeHash": "6d9f1f7ca0faf1bc2eeb397c78a49623260d3412", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1725001927, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "6e99f2a27d600612004fbd2c3282d614bfee6421", + "treeHash": "1e85443cc9f0ba302df2cf61cacb8014943e2d19", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1724857454, + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "4509ca64f1084e73bc7a721b20c669a8d4c5ebe6", + "treeHash": "ced5a8df7c554ce10bf26223c002f41b31aff034", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..afdeee7 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,31 @@ +{ pkgs, lib, config, inputs, ... }: + +{ + packages = with pkgs; [ fswatch jq gnumake ]; + + languages.javascript = { + enable = true; + + bun = { + enable = true; + package = pkgs.bun; + install = { + enable = true; + }; + }; + }; + + # https://devenv.sh/pre-commit-hooks/ + pre-commit.hooks.eslint = { + enable = true; + entry = "bunx eslint"; + files = "\\.(ts|js)$"; + }; + pre-commit.hooks.prettier = { + enable = true; + entry = "bunx prettier -w"; + files = "\\.(ts|js|json|ya?ml|md)$"; + }; + + # See full reference at https://devenv.sh/reference/options/ +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..fefdd49 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,14 @@ +# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json +inputs: + nixpkgs: + url: github:cachix/devenv-nixpkgs/rolling +# If you're using non-OSS software, you can set allowUnfree to true. +# allowUnfree: true + +# If you're willing to use a package that's vulnerable +# permittedInsecurePackages: +# - "openssl-1.1.1w" + +# If you have more than one devenv you can merge them +#imports: +# - ./backend diff --git a/package.json b/package.json index 882f0f0..59ce7fd 100644 --- a/package.json +++ b/package.json @@ -54,5 +54,8 @@ "repository": { "type": "git", "url": "https://github.com/dszakallas/mixxx-launchpad.git" + }, + "dependencies": { + "caniuse-lite": "" } }