Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
pull_request:
push:
branches: [master]

jobs:
build-dev-env:
name: Build dev env
strategy:
matrix:
os:
- ubuntu-latest
# This is too expensive
# - macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: cachix/install-nix-action@v14.1
- uses: cachix/cachix-action@v10
with:
name: wire-server
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: Build the wire-server-direnv
run: nix-build --no-out-link direnv.nix
- name: Install the wire-server-direnv
run: nix-env -f direnv.nix -i
- name: Ensure everything is formatted
run: make formatc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have a concourse check for the formatc thing; so these last two lines are not really necessary I'd say; but sure we can have the check run twice in case one CI is down.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concourse CI Logs aren't visible externally, and in the past, they were red for quite some time without getting fixed. Having CI definitons in the same repo, and public readable logs allows everyone to send a PR to fix it.

It'd be pretty simple to require that gh actions pipeline to be green before merging. Adding a separate concourse pipeline only for that purpose would be much more involved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ormolu check from concourse is behaving just fine and hasn't had any problems I'm aware of. As for the "visible logs for externals", there is a believe an ongoing project for a concourse-on-k8s-for-CI from the PIT team that would solve that part, but not just for ormolu, but also for all the other checks that currently run on CI.

I already approved the PR so I'm not against adding this check a second time, it's just providing little extra value at this point IMO.

1 change: 1 addition & 0 deletions changelog.d/5-internal/ormolu-direnv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add ormolu to the direnv, add a GH Action to ensure formatting
69 changes: 38 additions & 31 deletions direnv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,49 @@ let

src =
if pkgs.stdenv.isDarwin
then pkgs.fetchurl {
url = darwinAmd64Url;
sha256 = darwinAmd64Sha256;
}
else pkgs.fetchurl {
url = linuxAmd64Url;
sha256 = linuxAmd64Sha256;
};
then
pkgs.fetchurl
{
url = darwinAmd64Url;
sha256 = darwinAmd64Sha256;
}
else
pkgs.fetchurl {
url = linuxAmd64Url;
sha256 = linuxAmd64Sha256;
};

installPhase = ''
mkdir -p $out/bin
cp ${binPath} $out/bin
'';
};

staticBinary = { pname, version, linuxAmd64Url, linuxAmd64Sha256, darwinAmd64Url, darwinAmd64Sha256, binPath ? pname }:
pkgs.stdenv.mkDerivation {
inherit pname version;

src =
if pkgs.stdenv.isDarwin
then pkgs.fetchurl {
url = darwinAmd64Url;
sha256 = darwinAmd64Sha256;
}
else pkgs.fetchurl {
staticBinary = { pname, version, linuxAmd64Url, linuxAmd64Sha256, darwinAmd64Url, darwinAmd64Sha256, binPath ? pname }:
pkgs.stdenv.mkDerivation {
inherit pname version;

src =
if pkgs.stdenv.isDarwin
then
pkgs.fetchurl
{
url = darwinAmd64Url;
sha256 = darwinAmd64Sha256;
}
else
pkgs.fetchurl {
url = linuxAmd64Url;
sha256 = linuxAmd64Sha256;
};
phases = ["installPhase" "patchPhase"];
phases = [ "installPhase" "patchPhase" ];

installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/${binPath}
chmod +x $out/bin/${binPath}
'';
};
installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/${binPath}
chmod +x $out/bin/${binPath}
'';
};

pinned = {
stack = staticBinaryInTarball {
Expand Down Expand Up @@ -102,17 +108,19 @@ let
linuxAmd64Sha256 = "949f81b3c30ca03a3d4effdecda04f100fa3edc07a28b19400f72ede7c5f0491";
};
};
in pkgs.buildEnv {
in
pkgs.buildEnv {
name = "wire-server-direnv";
paths = [
pkgs.cfssl
pkgs.docker-compose
pkgs.gnumake
pkgs.grpcurl
pkgs.haskell-language-server
pkgs.telepresence
pkgs.jq
pkgs.grpcurl
pkgs.ormolu
pkgs.telepresence
pkgs.wget
pkgs.cfssl
pkgs.yq

# To actually run buildah on nixos, I had to follow this: https://gist.github.com/alexhrescale/474d55635154e6b2cd6362c3bb403faf
Expand All @@ -125,4 +133,3 @@ in pkgs.buildEnv {
pinned.kind
];
}

12 changes: 5 additions & 7 deletions tools/ormolu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ set -e

cd "$( dirname "${BASH_SOURCE[0]}" )/.."

command -v grep >/dev/null 2>&1 || { echo >&2 "grep is not installed, aborting."; exit 1; }
command -v sed >/dev/null 2>&1 || { echo >&2 "sed is not installed, aborting."; exit 1; }

ORMOLU_VERSION=$(sed -n '/^extra-deps:/,$ { s/^- ormolu-//p }' < stack.yaml)
( ormolu -v 2>/dev/null | grep -q $ORMOLU_VERSION ) || ( echo "please install ormolu $ORMOLU_VERSION (eg., run 'stack install ormolu' and ensure ormolu is on your PATH.)"; exit 1 )
echo "ormolu version: $ORMOLU_VERSION"

ARG_ALLOW_DIRTY_WC="0"
ARG_ORMOLU_MODE="inplace"

Expand Down Expand Up @@ -74,6 +67,11 @@ if [ -t 1 ]; then
: ${ORMOLU_CONDENSE_OUTPUT:=1}
fi

# https://github.com/tweag/ormolu/issues/38
# https://gitlab.haskell.org/ghc/ghc/-/issues/17755
export LANG=C.UTF-8
export LC_ALL=C.UTF-8

for hsfile in $(git ls-files | grep '\.hsc\?$'); do
FAILED=0

Expand Down