diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000000..ac692eec191 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/changelog.d/5-internal/ormolu-direnv b/changelog.d/5-internal/ormolu-direnv new file mode 100644 index 00000000000..ae0dddfd756 --- /dev/null +++ b/changelog.d/5-internal/ormolu-direnv @@ -0,0 +1 @@ +Add ormolu to the direnv, add a GH Action to ensure formatting diff --git a/direnv.nix b/direnv.nix index c29ac40da57..07281107a66 100644 --- a/direnv.nix +++ b/direnv.nix @@ -6,14 +6,17 @@ 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 @@ -21,28 +24,31 @@ let ''; }; - 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 { @@ -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 @@ -125,4 +133,3 @@ in pkgs.buildEnv { pinned.kind ]; } - diff --git a/tools/ormolu.sh b/tools/ormolu.sh index 99734e27569..e34fddf3015 100755 --- a/tools/ormolu.sh +++ b/tools/ormolu.sh @@ -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" @@ -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