From 4136c9e1804df5d5a2ed436db4ecb865d53e4caf Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Fri, 10 Mar 2023 08:15:59 +1300 Subject: [PATCH 1/4] chore: Ignore JetBrains IDEA configuration --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index ffdd18cd..c8b55325 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,6 @@ typings/ # DynamoDB Local files .dynamodb/ + +# JetBrains IDEA configuration +/.idea/ From 13cf34062037d3f199f154324b04d45727d9aa52 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Fri, 10 Mar 2023 08:30:04 +1300 Subject: [PATCH 2/4] refactor: Format files using Prettier Actual command: `nix-shell --packages nodePackages.prettier --pure --run 'prettier --write .'`. --- .github/dependabot.yml | 19 +++--- .github/workflows/test.yml | 134 ++++++++++++++++++------------------- README.md | 23 +++---- action.yml | 26 +++---- 4 files changed, 100 insertions(+), 102 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1a1a1c85..66647b53 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,13 +1,12 @@ version: 2 updates: - -- package-ecosystem: github-actions - directory: "/" - schedule: - interval: daily - time: '00:00' - timezone: UTC - open-pull-requests-limit: 10 - commit-message: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: daily + time: "00:00" + timezone: UTC + open-pull-requests-limit: 10 + commit-message: prefix: "chore" - include: "scope" \ No newline at end of file + include: "scope" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a31337fb..0eea3c35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,111 +18,111 @@ jobs: fail-fast: false matrix: os: - - ubuntu-latest - - macos-latest - - macos-13 + - ubuntu-latest + - macos-latest + - macos-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Install Nix - uses: ./ - with: - nix_path: ${{ env.nixpkgs_channel }} - - run: nix-env -iA cachix -f https://cachix.org/api/v1/install - - run: cat /etc/nix/nix.conf - # cachix should be available and be able to configure a cache - - run: cachix use cachix - - run: nix-build test.nix + - uses: actions/checkout@v4 + - name: Install Nix + uses: ./ + with: + nix_path: ${{ env.nixpkgs_channel }} + - run: nix-env -iA cachix -f https://cachix.org/api/v1/install + - run: cat /etc/nix/nix.conf + # cachix should be available and be able to configure a cache + - run: cachix use cachix + - run: nix-build test.nix custom-nix-path: strategy: fail-fast: false matrix: os: - - ubuntu-latest - - macos-latest - - macos-13 + - ubuntu-latest + - macos-latest + - macos-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Install Nix - uses: ./ - with: - nix_path: ${{ env.nixpkgs_channel }} - - run: test $NIX_PATH == '${{ env.nixpkgs_channel }}' - - run: nix-build test.nix + - uses: actions/checkout@v4 + - name: Install Nix + uses: ./ + with: + nix_path: ${{ env.nixpkgs_channel }} + - run: test $NIX_PATH == '${{ env.nixpkgs_channel }}' + - run: nix-build test.nix extra-nix-config: strategy: fail-fast: false matrix: os: - - ubuntu-latest - - macos-latest - - macos-13 + - ubuntu-latest + - macos-latest + - macos-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Install Nix - uses: ./ - with: - nix_path: ${{ env.nixpkgs_channel }} - extra_nix_config: | - sandbox = relaxed - - run: cat /etc/nix/nix.conf - - run: nix-build test.nix --arg noChroot true + - uses: actions/checkout@v4 + - name: Install Nix + uses: ./ + with: + nix_path: ${{ env.nixpkgs_channel }} + extra_nix_config: | + sandbox = relaxed + - run: cat /etc/nix/nix.conf + - run: nix-build test.nix --arg noChroot true flakes: strategy: fail-fast: false matrix: os: - - ubuntu-latest - - macos-latest - - macos-13 + - ubuntu-latest + - macos-latest + - macos-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Install Nix - uses: ./ - - run: nix flake show github:NixOS/nixpkgs + - uses: actions/checkout@v4 + - name: Install Nix + uses: ./ + - run: nix flake show github:NixOS/nixpkgs installer-options: strategy: fail-fast: false matrix: os: - - ubuntu-latest - # - macos-latest missing installer for aarch64-darwin - - macos-13 + - ubuntu-latest + # - macos-latest missing installer for aarch64-darwin + - macos-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Install Nix - uses: ./ - with: - nix_path: ${{ env.nixpkgs_channel }} - install_options: --tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve - install_url: https://nixos-nix-install-tests.cachix.org/serve/${{ env.pinned_installer_hash }}/install - - run: nix-build test.nix + - uses: actions/checkout@v4 + - name: Install Nix + uses: ./ + with: + nix_path: ${{ env.nixpkgs_channel }} + install_options: --tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve + install_url: https://nixos-nix-install-tests.cachix.org/serve/${{ env.pinned_installer_hash }}/install + - run: nix-build test.nix oldest-supported-installer: strategy: fail-fast: false matrix: os: - - ubuntu-latest - - macos-latest - - macos-13 + - ubuntu-latest + - macos-latest + - macos-13 runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Install Nix - uses: ./ - with: - nix_path: ${{ env.nixpkgs_channel }} - install_url: https://releases.nixos.org/nix/${{ env.oldest_supported_installer }}/install - - run: nix-build test.nix + - uses: actions/checkout@v4 + - name: Install Nix + uses: ./ + with: + nix_path: ${{ env.nixpkgs_channel }} + install_url: https://releases.nixos.org/nix/${{ env.oldest_supported_installer }}/install + - run: nix-build test.nix act-support: strategy: @@ -130,7 +130,7 @@ jobs: os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - run: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash - - run: docker pull ghcr.io/catthehacker/ubuntu:js-20.04 - - run: ./bin/act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:js-20.04 push -j simple-build + - uses: actions/checkout@v4 + - run: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash + - run: docker pull ghcr.io/catthehacker/ubuntu:js-20.04 + - run: ./bin/act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:js-20.04 push -j simple-build diff --git a/README.md b/README.md index d5609dbf..90d6436f 100644 --- a/README.md +++ b/README.md @@ -33,11 +33,11 @@ jobs: tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v27 - with: - nix_path: nixpkgs=channel:nixos-unstable - - run: nix-build + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + with: + nix_path: nixpkgs=channel:nixos-unstable + - run: nix-build ``` ## Usage with Flakes @@ -51,12 +51,12 @@ jobs: tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v27 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - run: nix build - - run: nix flake check + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v27 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + - run: nix build + - run: nix flake check ``` To install Nix from any commit, go to [the corresponding installer_test action](https://github.com/NixOS/nix/runs/2219534360) and click on "Run cachix/install-nix-action@XX" step and expand the first line. @@ -75,7 +75,6 @@ To install Nix from any commit, go to [the corresponding installer_test action]( - `enable_kvm`: whether to enable KVM for hardware-accelerated virtualization on Linux. Enabled by default if available. - ## Differences from the default Nix installer Some settings have been optimised for use in CI environments: diff --git a/action.yml b/action.yml index d33114a0..c35ec7d2 100644 --- a/action.yml +++ b/action.yml @@ -1,28 +1,28 @@ -name: 'Install Nix' -description: 'Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.' -author: 'Domen Kožar' +name: "Install Nix" +description: "Installs Nix on GitHub Actions for the supported platforms: Linux and macOS." +author: "Domen Kožar" inputs: extra_nix_config: - description: 'Gets appended to `/etc/nix/nix.conf` if passed.' + description: "Gets appended to `/etc/nix/nix.conf` if passed." github_access_token: - description: 'Configure nix to pull from github using the given github token.' + description: "Configure nix to pull from github using the given github token." install_url: - description: 'Installation URL that will contain a script to install Nix.' + description: "Installation URL that will contain a script to install Nix." install_options: - description: 'Additional installer flags passed to the installer script.' + description: "Additional installer flags passed to the installer script." nix_path: - description: 'Set NIX_PATH environment variable.' + description: "Set NIX_PATH environment variable." enable_kvm: - description: 'Enable KVM for hardware-accelerated virtualization on Linux, if available.' + description: "Enable KVM for hardware-accelerated virtualization on Linux, if available." required: false default: true branding: - color: 'blue' - icon: 'sun' + color: "blue" + icon: "sun" runs: - using: 'composite' + using: "composite" steps: - - run : ${GITHUB_ACTION_PATH}/install-nix.sh + - run: ${GITHUB_ACTION_PATH}/install-nix.sh shell: bash env: INPUT_EXTRA_NIX_CONFIG: ${{ inputs.extra_nix_config }} From 4f73b39fc11f9ba682b3cb5beaebbb4df2e48319 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Fri, 10 Mar 2023 08:31:12 +1300 Subject: [PATCH 3/4] feat: Enable automatically formatting code using pre-commit --- .pre-commit-config.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..fa03b8ff --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,9 @@ +# Configuration file for pre-commit (https://pre-commit.com/). +# Please run `pre-commit run --all-files` when adding or changing entries. + +repos: + - repo: https://github.com/pre-commit/mirrors-prettier + rev: 6f3cb139ef36133b6f903b97facc57b07cef57c9 # frozen: v3.0.0-alpha.6 + hooks: + - id: prettier + stages: [commit] From 84ef05d44213a64b85ff60c52917672b0f72f129 Mon Sep 17 00:00:00 2001 From: Victor Engmark Date: Fri, 10 Mar 2023 08:33:46 +1300 Subject: [PATCH 4/4] feat: Check formatting as part of CI --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0eea3c35..5a93b0b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -134,3 +134,13 @@ jobs: - run: curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash - run: docker pull ghcr.io/catthehacker/ubuntu:js-20.04 - run: ./bin/act -P ubuntu-latest=ghcr.io/catthehacker/ubuntu:js-20.04 push -j simple-build + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install Nix + uses: ./ + with: + nix_path: nixpkgs=channel:nixos-22.11 + - run: nix-shell --packages cacert git nodejs pre-commit --pure --run 'pre-commit run --all-files'