From c4a369b4f51817155bd8cb56020bf5bb67d95448 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Sun, 23 May 2021 10:41:00 +0800 Subject: [PATCH 1/5] Use cabal-install if nix is failing in CI --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 74f5720b54..036b34a704 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -47,7 +47,7 @@ jobs: name: haskell-language-server authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} - run: nix build + run: nix build || (nix develop --command cabal update && nix develop --command cabal build) - if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }} run: nix develop --profile dev && cachix push haskell-language-server dev - if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }} From c73c49fe9843a1e5d992cd858c01a7d1c5629a6f Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Sun, 23 May 2021 10:41:14 +0800 Subject: [PATCH 2/5] Add default.nix --- default.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..d87fd23886 --- /dev/null +++ b/default.nix @@ -0,0 +1,11 @@ +# This file is the compt layer of flakes: https://github.com/edolstra/flake-compat +# See flake.nix for details +(import ( + let + lock = builtins.fromJSON (builtins.readFile ./flake.lock); + in fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; } +) { + src = ./.; +}).defaultNix From 41a8f09d106aa401600f93685fb9cd5f4b099cc7 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Sun, 23 May 2021 14:13:35 +0800 Subject: [PATCH 3/5] Split nix job --- .github/workflows/nix.yml | 53 +++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 036b34a704..fb9351404c 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -4,6 +4,9 @@ on: pull_request: branches: - '**' + push: + branches: + - master jobs: pre_job: @@ -17,11 +20,10 @@ jobs: cancel_others: true paths_ignore: '["**/docs/**", "**.md", "**/LICENSE", ".circleci/**", "install/**"]' - nix: + # Enter the development shell and run `cabal build` + develop: needs: pre_job runs-on: ${{ matrix.os }} - env: - HAS_TOKEN: ${{ secrets.HLS_CACHIX_AUTH_TOKEN != '' }} strategy: fail-fast: false @@ -41,14 +43,43 @@ jobs: extra_nix_config: | experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable - - if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }} - uses: cachix/cachix-action@v8 + - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + uses: cachix/cachix-action@v10 with: name: haskell-language-server - authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} + # Disable pushing, we will do that in job `build` + skipPush: true - if: ${{ needs.pre_job.outputs.should_skip != 'true' }} - run: nix build || (nix develop --command cabal update && nix develop --command cabal build) - - if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }} - run: nix develop --profile dev && cachix push haskell-language-server dev - - if: ${{ needs.pre_job.outputs.should_skip != 'true' && env.HAS_TOKEN == 'true' }} - run: nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server + run: | + nix develop --command cabal update + nix develop --command cabal build + + # Build and then push HLS binaries with developmet shell to cachix + # This job runs when PRs are merged to master, and should be excluded from branch protections + build: + runs-on: ${{ matrix.os }} + if: ${{ github.repository_owner == 'haskell' && github.ref == 'ref/heads/master' }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macOS-latest] + + steps: + uses: actions/checkout@v2 + with: + submodules: true + uses: cachix/install-nix-action@v13 + with: + install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install + install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' + extra_nix_config: | + experimental-features = nix-command flakes + nix_path: nixpkgs=channel:nixos-unstable + uses: cachix/cachix-action@v10 + with: + name: haskell-language-server + authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} + run: | + nix build + nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server + nix develop --profile dev && cachix push haskell-language-server dev From 20d2e9a135493807dbeaaf5dfbadbaf928699931 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Sun, 23 May 2021 14:18:48 +0800 Subject: [PATCH 4/5] Fix syntax error --- .github/workflows/nix.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index fb9351404c..0f51db1456 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -65,21 +65,21 @@ jobs: os: [ubuntu-latest, macOS-latest] steps: - uses: actions/checkout@v2 + - uses: actions/checkout@v2 with: submodules: true - uses: cachix/install-nix-action@v13 + - uses: cachix/install-nix-action@v13 with: install_url: https://nixos-nix-install-tests.cachix.org/serve/lb41az54kzk6j12p81br4bczary7m145/install install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve' extra_nix_config: | experimental-features = nix-command flakes nix_path: nixpkgs=channel:nixos-unstable - uses: cachix/cachix-action@v10 + - uses: cachix/cachix-action@v10 with: name: haskell-language-server authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - run: | + - run: | nix build nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server nix develop --profile dev && cachix push haskell-language-server dev From 84dea7539154a3857b2f630e475ab600f1f1b8a8 Mon Sep 17 00:00:00 2001 From: Potato Hatsue <1793913507@qq.com> Date: Sun, 23 May 2021 14:59:52 +0800 Subject: [PATCH 5/5] Reorder --- .github/workflows/nix.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 0f51db1456..4bf30440ce 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -80,6 +80,6 @@ jobs: name: haskell-language-server authToken: ${{ secrets.HLS_CACHIX_AUTH_TOKEN }} - run: | + nix develop --profile dev && cachix push haskell-language-server dev nix build nix path-info --json | jq -r '.[].path' | cachix push haskell-language-server - nix develop --profile dev && cachix push haskell-language-server dev