From 8a41ed3fd382334ac4fa9509317ff0b566871f7e Mon Sep 17 00:00:00 2001 From: eikek Date: Sun, 10 Mar 2024 15:50:06 +0100 Subject: [PATCH] Github actions use nix --- .github/workflows/ci-docs.yml | 9 +++------ .github/workflows/ci.yml | 20 +++----------------- .github/workflows/docker-image.yml | 2 +- .github/workflows/release-nightly.yml | 24 ++++-------------------- .github/workflows/release.yml | 20 +++----------------- .github/workflows/website.yml | 11 ++++------- flake.nix | 22 ++++++++++++++-------- 7 files changed, 32 insertions(+), 76 deletions(-) diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-docs.yml index 15de027f..e2fa7bca 100644 --- a/.github/workflows/ci-docs.yml +++ b/.github/workflows/ci-docs.yml @@ -6,16 +6,13 @@ on: - "master" jobs: check-website: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 + - uses: cachix/install-nix-action@v26 - name: Set current version run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV - - uses: jorelali/setup-elm@v5 - with: - elm-version: 0.19.1 - - uses: cachix/install-nix-action@v26 - name: Build website (${{ env.DOCSPELL_VERSION }}) - run: nix develop .#dev-cnt --command sbt make-website + run: nix develop .#ci --command sbt make-website diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 873d0ab2..272a9654 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,32 +5,18 @@ on: - master jobs: ci-matrix: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: fail-fast: false - matrix: - java: [ 'openjdk@1.17' ] steps: - uses: actions/checkout@v4.1.1 with: fetch-depth: 100 - - uses: jorelali/setup-elm@v5 - with: - elm-version: 0.19.1 - - uses: bahmutov/npm-install@v1 - with: - working-directory: modules/webapp - name: Fetch tags run: git fetch --depth=100 origin +refs/tags/*:refs/tags/* - - uses: olafurpg/setup-scala@v14 - with: - java-version: ${{ matrix.java }} - # - name: Coursier cache - # uses: coursier/cache-action@v6 + - uses: cachix/install-nix-action@v26 - name: sbt ci ${{ github.ref }} - run: sbt ci - env: - SBT_OPTS: "-Xmx2G -Xss4m" + run: nix develop .#ci --command sbt ci ci: runs-on: ubuntu-22.04 needs: [ci-matrix] diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 997e0972..77e2a3a0 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -4,7 +4,7 @@ on: types: [ published ] jobs: docker-images: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 with: diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index fa371efa..ec18ef90 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -5,36 +5,20 @@ on: - "master" jobs: release-nightly: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: fail-fast: true - matrix: - java: [ 'openjdk@1.17' ] steps: - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - - uses: olafurpg/setup-scala@v14 - with: - java-version: ${{ matrix.java }} - - uses: jorelali/setup-elm@v5 - with: - elm-version: 0.19.1 - - uses: bahmutov/npm-install@v1 - with: - working-directory: modules/webapp - # - name: Coursier cache - # uses: coursier/cache-action@v6 + - uses: cachix/install-nix-action@v26 - name: Set current version run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV - name: sbt ci ${{ github.ref }} - run: sbt ci - env: - SBT_OPTS: "-Xmx2G -Xss4m" + run: nix develop .#ci --command sbt ci - name: sbt make-pkg (${{ env.DOCSPELL_VERSION }}) - run: sbt make-pkg - env: - SBT_OPTS: "-Xmx2G -Xss4m" + run: nix develop .#ci --command sbt make-pkg - uses: "marvinpinto/action-automatic-releases@latest" with: repo_token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 49d33cb9..9a55c2f2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,32 +5,18 @@ on: - 'v*' jobs: release: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest strategy: fail-fast: true - matrix: - java: [ 'openjdk@1.17' ] steps: - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - - uses: olafurpg/setup-scala@v14 - with: - java-version: ${{ matrix.java }} - - uses: jorelali/setup-elm@v5 - with: - elm-version: 0.19.1 - - uses: bahmutov/npm-install@v1 - with: - working-directory: modules/webapp - # - name: Coursier cache - # uses: coursier/cache-action@v6 + - uses: cachix/install-nix-action@v26 - name: Set current version run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV - name: sbt make-pkg (${{ env.DOCSPELL_VERSION }}) - run: sbt make-pkg - env: - SBT_OPTS: "-Xmx2G -Xss4m" + run: nix develop .#ci --command sbt make-pkg - uses: meeDamian/github-release@2.0 with: token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 375d7f67..fa02f578 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -5,20 +5,17 @@ on: - "current-docs" jobs: publish-website: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 + - uses: cachix/install-nix-action@v26 - name: Set current version run: echo "DOCSPELL_VERSION=$(cat version.sbt | grep version | cut -d= -f2 | xargs)" >> $GITHUB_ENV - - uses: jorelali/setup-elm@v5 - with: - elm-version: 0.19.1 - - uses: cachix/install-nix-action@v26 - name: Build website (${{ env.DOCSPELL_VERSION }}) - run: nix develop .#dev-cnt --command sbt make-website + run: nix develop .#ci --command sbt make-website - name: Publish website (${{ env.DOCSPELL_VERSION }}) env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: nix develop .#dev-cnt --command sbt publish-website + run: nix develop .#ci --command sbt publish-website diff --git a/flake.nix b/flake.nix index 4acb2d17..513af86f 100644 --- a/flake.nix +++ b/flake.nix @@ -16,22 +16,24 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; sbt17 = pkgs.sbt.override { jre = pkgs.jdk17; }; - devshellPkgs = with pkgs; [ - jq - scala-cli + ciPkgs = with pkgs; [ sbt17 - - netcat jdk17 - wget - which dpkg elmPackages.elm fakeroot zola yarn - inotifyTools + nodejs ]; + devshellPkgs = ciPkgs ++ (with pkgs; [ + jq + scala-cli + netcat + wget + which + inotifyTools + ]); docspellPkgs = pkgs.callPackage (import ./nix/pkg.nix) {}; dockerAmd64 = pkgs.pkgsCross.gnu64.callPackage (import ./nix/docker.nix) { inherit (docspellPkgs) docspell-restserver docspell-joex; @@ -101,6 +103,10 @@ DEV_VM = "dev-vm"; VM_SSH_PORT = "10022"; }; + ci = pkgs.mkShellNoCC { + buildInputs = ciPkgs; + SBT_OPTS = "-Xmx2G -Xss4m"; + }; }; }) // {