Skip to content

Commit

Permalink
.github: use Nix to build Git
Browse files Browse the repository at this point in the history
  • Loading branch information
zombiezen committed Jul 28, 2023
1 parent cbce223 commit b20b07d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 57 deletions.
67 changes: 18 additions & 49 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,90 +23,59 @@ on:
jobs:
linux:
name: Linux
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
matrix:
git:
- "2.27.0" # latest
- "2.25.1" # Ubuntu LTS 20.04 focal
- "2.20.1" # Debian buster
- "2.17.1" # Ubuntu LTS 18.04 bionic
- "2.27.0" # latest
- "2.25.1" # Ubuntu LTS 20.04 focal
- "2.20.1" # Debian buster
- "2.17.1" # Ubuntu LTS 18.04 bionic
steps:
- name: Install Git dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y --no-install-recommends \
gettext \
libcurl4-gnutls-dev \
libexpat1-dev \
libssl-dev \
libz-dev \
xz-utils
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.19"
- name: Check out code
uses: actions/checkout@v3
- name: Install Git
run: misc/build-git.bash ~/git ${{ matrix.git }}
- name: Download dependencies
run: go mod download
env:
GO111MODULE: on
- name: Install Nix
uses: cachix/install-nix-action@v22
- name: Run tests
run: |
PATH="$HOME/git/bin-wrappers:$PATH" \
git_attr="$(echo "$GIT_VERSION" | sed -e 's/\./_/g')"
nix shell ".#$git_attr" '.#go' --command \
go test \
-mod=readonly \
-v \
-race \
./...
env:
GIT_VERSION: ${{ matrix.git }}
GO111MODULE: on
mac:
name: macOS
runs-on: macOS-latest
steps:
- name: Install xz
run: brew update && brew install xz
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.19"
- name: Check out code
uses: actions/checkout@v3
- name: Install Git
run: misc/build-git.bash ~/git 2.27.0
- name: Download dependencies
run: go mod download
env:
GO111MODULE: on
- name: Install Nix
uses: cachix/install-nix-action@v22
- name: Run tests
run: |
PATH="$HOME/git/bin-wrappers:$PATH" \
git_attr="$(echo "$GIT_VERSION" | sed -e 's/\./_/g')"
nix shell ".#$git_attr" '.#go' --command \
go test \
-mod=readonly \
-v \
-race \
./...
env:
GO111MODULE: on
GIT_VERSION: "2.27.0"
windows:
name: Windows
runs-on: windows-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.19"
- name: Check out code
uses: actions/checkout@v3
- name: Download dependencies
run: go mod download
env:
GO111MODULE: on
go-version: "1.20"
- name: Run tests
run: go test -mod=readonly -v -race ./...
env:
GO111MODULE: on
16 changes: 8 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
let
pkgs = import nixpkgs { inherit system; };
in {
packages.go = pkgs.go_1_20;

packages.git = pkgs.git;

packages.git_2_17_1 = self.lib.buildGit {
Expand Down Expand Up @@ -79,16 +81,14 @@
outputs = [ "out" ];
});

devShells.default = self.lib.mkShell { inherit pkgs; };
devShells.default = pkgs.mkShell {
packages = [
self.packages.${system}.go
pkgs.git
];
};
}
) // {
lib.mkShell = { pkgs, git ? pkgs.git }: pkgs.mkShell {
packages = [
pkgs.go_1_20
git
];
};

lib.buildGit = { pkgs, packagePath, args ? {} }:
let
defaultArgs = {
Expand Down

0 comments on commit b20b07d

Please sign in to comment.