Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(gh-actions): Add initial CI pipeline config #3

Merged
merged 18 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
9a3db5c
ci(gh-actions): Add initial CI pipeline config
PetarKirov Apr 17, 2023
a97cdde
build(pkgs/ldc): Define the package for more platforms
PetarKirov Apr 18, 2023
598d5b3
refactor(shell.nix): Include `dmd` package only if the `hostPlatform`…
PetarKirov Apr 19, 2023
5962491
refactor(shell.nix): Remove nixpkgs fallback
PetarKirov Apr 19, 2023
b1e943a
feat(shell.nix): Use pkgs instance resulting from applying the flake …
PetarKirov Apr 19, 2023
00ab6c7
refactor(pkgs/default.nix): Split packages list based on the platform
PetarKirov Apr 19, 2023
51483cb
fix(dmd/binary): Ensure `autoPatchelfHook` is able to find `libgcc_s.…
PetarKirov Apr 21, 2023
d7cb7fb
fix(dmd/generic): Fix the dmd runnable_cxx parts of the checkPhase by…
PetarKirov Apr 21, 2023
de5bfe6
feat(pkgs): Expose `{dmd,ldc}-binary` packages
PetarKirov Apr 21, 2023
f0701db
build(flake.nix/inputs): Remove `flake-utils`
PetarKirov Apr 21, 2023
153e352
fix(dmd/generic): Set `CC` env variable for both the build and the ch…
PetarKirov Apr 24, 2023
c18e696
config(flake.nix): Add Cachix binary cache settings
PetarKirov May 1, 2023
5e77184
fix(scripts/fetch-binary): Allow skipping missing binary packages
PetarKirov May 6, 2023
319c5e0
feat(ldc/bootstrap): Upgrade to 1.32.1
PetarKirov May 6, 2023
6da7f89
feat(scripts): Add D-based implementation of fetch_binary script
PetarKirov Sep 4, 2023
dd52030
fix(pkgs/dmd/generic): Disable failing macos tests
PetarKirov Sep 20, 2023
b9b6bc2
feat(ldc/bootstrap): Upgrade to 1.34.0
PetarKirov Sep 20, 2023
e5384d9
ci(gh-actions): Allow ldc on macos to fail
PetarKirov Sep 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: '00:00'
timezone: UTC
open-pull-requests-limit: 10
commit-message:
prefix: "chore"
include: "scope"
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
Nix:
strategy:
fail-fast: false
matrix:
experimental: [false]
os: [ ubuntu-latest, macos-12 ]
pkg:
- dmd
- ldc
- dub
include:
- { experimental: true, pkg: ldc, os: macos-12 }
exclude:
- { experimental: false, pkg: ldc, os: macos-12 }

name: ${{ matrix.pkg }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}

steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v23
with:
# NIX_PATH is explicitly set to a wrong value to prevent accidental
# usage. `nixpkgs` should be accessed only through the locked flake
# reference.
nix_path: nixpkgs=null
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config:
accept-flake-config = true

- uses: cachix/cachix-action@v12
with:
name: dlang-community
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

- name: Build ${{ matrix.job_name }}
run: nix build -L --json --no-link '.#${{ matrix.pkg }}'
42 changes: 42 additions & 0 deletions .github/workflows/update-flake-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update Nix Flake lockfile

on:
# Enable option to manually run the action:
workflow_dispatch:

# Run every Sunday:
schedule:
- cron: 0 0 * * 0

jobs:
main:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
PetarKirov marked this conversation as resolved.
Show resolved Hide resolved
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Run `nix flake update`
id: update-lockfile
run: ./utils/commit_flake_update.bash

- uses: tibdex/[email protected]
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ steps.generate-token.outputs.token }}
title: 'Update Nix Flake lockfile'
commit-message: ${{ env.COMMIT_MSG }}
branch: 'create-pull-request/update-flake-lockfile'
delete-branch: true
branch-suffix: timestamp
add-paths: flake.lock
34 changes: 0 additions & 34 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{
description = "Nix packages for D projects";

nixConfig = {
extra-substituters = "https://dlang-community.cachix.org";
extra-trusted-public-keys = "dlang-community.cachix.org-1:eAX1RqX4PjTDPCAp/TvcZP+DYBco2nJBackkAJ2BsDQ=";
};

inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;

flake-parts = {
url = "github:hercules-ci/flake-parts";
Expand All @@ -20,8 +24,8 @@
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
imports = [./pkgs];
perSystem = {pkgs, ...}: {
devShells.default = import ./shell.nix {inherit pkgs;};
perSystem = {final, ...}: {
devShells.default = import ./shell.nix {pkgs = final;};
};
};
}
20 changes: 12 additions & 8 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@
pkgs,
...
}: let
inherit (pkgs) callPackage;
inherit (pkgs) callPackage lib darwin hostPlatform;
darwinPkgs = {
inherit (pkgs.darwin.apple_sdk.frameworks) Foundation;
inherit (darwin.apple_sdk.frameworks) Foundation;
};
in {
overlayAttrs = self'.packages;
packages = {
dmd = callPackage ./dmd ({} // darwinPkgs);
packages =
{
ldc-binary = callPackage ./ldc/bootstrap.nix {};
ldc = callPackage ./ldc {};

ldc = callPackage ./ldc {};

dub = callPackage ./dub {};
};
dub = callPackage ./dub {};
}
// lib.optionalAttrs hostPlatform.isx86 {
dmd-binary = callPackage ./dmd/bootstrap.nix {};
dmd = callPackage ./dmd darwinPkgs;
};
};
}
4 changes: 2 additions & 2 deletions pkgs/dmd/binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
tzdata,
autoPatchelfHook,
fixDarwinDylibNames,
glibc,
gccForLibs,
version,
hashes,
}: let
Expand Down Expand Up @@ -37,7 +37,7 @@ in
lib.optional hostPlatform.isLinux autoPatchelfHook
++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames;

propagatedBuildInputs = [curl tzdata] ++ lib.optional hostPlatform.isLinux glibc;
propagatedBuildInputs = [curl tzdata] ++ lib.optional hostPlatform.isLinux gccForLibs.libgcc;

installPhase = ''
runHook preInstall
Expand Down
9 changes: 8 additions & 1 deletion pkgs/dmd/generic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
curl,
tzdata,
gdb,
gcc11,
Foundation,
callPackage,
targetPackages,
Expand Down Expand Up @@ -78,6 +79,7 @@
"-fposix.mak"
"SHELL=${bash}/bin/bash"
"DMD=$(NIX_BUILD_TOP)/dmd/${buildPath}/dmd"
"CC=${if stdenv.isDarwin then stdenv.cc else gcc11}/bin/cc"
"HOST_DMD=${HOST_DMD}"
"PIC=1"
"BUILD=${buildMode}"
Expand Down Expand Up @@ -197,6 +199,9 @@ in
substituteInPlace phobos/std/socket.d --replace "assert(ih.addrList[0] == 0x7F_00_00_01);" ""
''
+ lib.optionalString stdenv.isDarwin ''
rm dmd/test/runnable/{test13117.d,test13117b.d}
rm dmd/test/runnable_cxx/{cpp11.d,cppa.d,cpp_stdlib.d}

substituteInPlace phobos/std/socket.d --replace "foreach (name; names)" "names = []; foreach (name; names)"
'';

Expand Down Expand Up @@ -236,7 +241,9 @@ in

inherit doCheck;

checkFlags = commonBuildFlags ++ ["CC=${stdenv.cc}/bin/cc" "N=$(checkJobs)"];
checkInputs = lib.optional stdenv.isDarwin Foundation;

checkFlags = commonBuildFlags ++ ["N=$(checkJobs)"];

# many tests are disbled because they are failing

Expand Down
39 changes: 27 additions & 12 deletions pkgs/ldc/binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,37 @@
version,
hashes,
}: let
inherit (stdenv) hostPlatform;
OS =
if hostPlatform.isDarwin
then "osx"
else hostPlatform.parsed.kernel.name;
ARCH =
if hostPlatform.isDarwin && hostPlatform.isAarch64
then "arm64"
else hostPlatform.parsed.cpu.name;
inherit (stdenv) hostPlatform system;

systemToArchivePlatform = {
# FIXME: How should Android be supported?
# (It is not a separate Nixpkgs platform.)
"aarch64-android" = "android-aarch64";
"armv7a-android" = "android-armv7a";
"x86_64-freebsd" = "freebsd-x86_64";
"aarch64-linux" = "linux-aarch64";
"x86_64-linux" = "linux-x86_64";
"aarch64-darwin" = "osx-arm64";
"x86_64-darwin" = "osx-x86_64";
"x86_64-windows" = "windows-x64";
"i686-windows" = "windows-x86";
};

tarballSuffix =
if hostPlatform.isWindows
then "7z"
else "tar.xz";

archivePlatform = systemToArchivePlatform."${system}";
in
stdenv.mkDerivation {
pname = "ldc-binary";
inherit version;

src = fetchurl rec {
name = "ldc2-${version}-${OS}-${ARCH}.tar.xz";
name = "ldc2-${version}-${archivePlatform}.${tarballSuffix}";
url = "https:/ldc-developers/ldc/releases/download/v${version}/${name}";
sha256 = hashes."${OS}-${ARCH}" or (throw "missing bootstrap sha256 for ${OS}-${ARCH}");
sha256 = hashes."${archivePlatform}" or (throw "missing bootstrap sha256 for ${archivePlatform}");
};

dontConfigure = true;
Expand All @@ -53,6 +66,8 @@ in
# from https:/ldc-developers/ldc/blob/master/LICENSE
license = with licenses; [bsd3 boost mit ncsa gpl2Plus];
maintainers = with maintainers; [ThomasMader lionello];
platforms = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
# FIXME: change to the following after the CI verifies it:
# platforms = builtins.attrNames systemToArchivePlatform;
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
};
}
17 changes: 11 additions & 6 deletions pkgs/ldc/bootstrap.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{callPackage}:
callPackage ./binary.nix {
version = "1.28.0";
version = "1.34.0";
hashes = {
# COMPILER=ldc VERSION='1.28.0' ./scripts/fetch-binary
"linux-x86_64" = "sha256-l4bDbE39Kd0wilDEmcEV5MIHm66t7QflrFOWxKf9Ang=";
"linux-aarch64" = "sha256-9zo22af/3QAK6sNy8gKFCztlgkqnmZj3H5Ud8deTdGU=";
"osx-x86_64" = "sha256-AkclB96YjItd2DsYnG3ztHR0FUZYlJbC/z1nPya40Jo=";
"osx-arm64" = "sha256-+XhrjCjYrx/dMx2OuImt2AKF2+v7l+pH1d2REKffB0s=";
# ./scripts/fetch_binary.d --compiler=ldc --version=1.34.0 --dry-run=false
"android-aarch64" = "sha256-SJRdpd5tzhLPhJuY6rhN7r0Z2gCvEVDZxDMj0+tufUc=";
"android-armv7a" = "sha256-1URd7kpVA5m8DOPLO+6M3xhKvztHwIvNj2oka8TFcYw=";
"freebsd-x86_64" = "sha256-vI/ubxF0wyw/KdyoVzv7g4/6JiyJOdwgb/N7T6rne14=";
"linux-aarch64" = "sha256-LRD817uG0XMf6i+GaqCi/vDuURU4WInhFCeU+dAtHaE=";
"linux-x86_64" = "sha256-cnmsxGlsElSE2iVQcs+KVHKsKMv6XYin4N+XhUFt/BU=";
"osx-arm64" = "sha256-W45AEOW1EPsxizCgJYUOZyq7MhotN62xobsEAbr2/tU=";
"osx-x86_64" = "sha256-93aJN7ZNOLrQmKd6z/435trWg5F6B3XfOmKU/j5M5ig=";
"windows-x64" = "sha256-WrZnrDo/8hnsOsY2Ih8txErDz3OaNhVzwFFXsPJCEFM=";
"windows-x86" = "sha256-Vu/W9z7cB7VrcBqrlClknCYYni+GCDB4baGZOT6JS54=";
};
}
8 changes: 6 additions & 2 deletions scripts/fetch-binary
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ main() {
echo "-----"
for platform in "${platforms[@]}"; do
url="$(getUrl "$platform")"
hash="$(prefech "$url")"
hash="$(prefech "$url")" || continue
hashes[$platform]="$hash"
done

Expand All @@ -28,7 +28,11 @@ main() {
echo

for platform in "${platforms[@]}"; do
echo "\"${platform}\" = \"${hashes[$platform]}\";"
if [[ -v 'hashes[$platform]' ]]; then
echo "\"${platform}\" = \"${hashes[$platform]}\";"
else
echo "# \"${platform}\" = \"<not available>\";"
fi
done
}

Expand Down
Loading
Loading