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

Setup confer-head prereleases #5

Merged
merged 1 commit into from
Jun 24, 2024
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
116 changes: 108 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ name: CI
on:
pull_request:
push:
branches: ["main"]
branches: ['main']

jobs:
generate-matrix:
name: "Generate matrix from cabal"
outputs:
name: 'Generate matrix from cabal'
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
Expand All @@ -18,8 +18,8 @@ jobs:
uses: kleidukos/[email protected]
with:
cabal-file: confer.cabal
ubuntu-version: "latest"
macos: "macos-13"
ubuntu-version: 'latest'
macos: 'macos-13'
version: 0.1.7.0
tests:
name: ${{ matrix.ghc }} on ${{ matrix.os }}
Expand All @@ -39,14 +39,114 @@ jobs:
- name: Configure
run: cabal configure --enable-tests
- name: Freeze
run: cabal freeze
run: cabal freeze --project-file=cabal.release.project
- name: Cache
uses: actions/[email protected]
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ runner.os }}-ghc-${{ matrix.ghc }}-
- name: Build
run: cabal new-build
run: cabal build --project-file=cabal.release.project
- name: Test
run: cabal new-test all
run: cabal test --project-file=cabal.release.project all
- name: Package the confer-head executable
run: |
CONFER_EXEC=$(cabal list-bin --project-file=cabal.release.project confer:exe:confer)
DIR=$(dirname $CONFER_EXEC)
FILE=$(basename $CONFER_EXEC)
CONFER_EXEC_TAR=confer-head-${{ runner.os }}-x86_64.tar.gz
tar -czvf $CONFER_EXEC_TAR -C $DIR $FILE
echo CONFER_EXEC_TAR=$CONFER_EXEC_TAR >> $GITHUB_ENV
- name: Upload the confer-head executable
uses: actions/upload-artifact@v3
with:
name: confer-${{ runner.os }}-x86_64
path: ${{ env.CONFER_EXEC_TAR }}

build-alpine:
name: Build statically linked using alpine
runs-on: ubuntu-latest
container: 'alpine:3.19'
needs: ['generate-matrix', 'tests']
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Install extra dependencies
shell: sh
run: |
apk add bash curl sudo jq pkgconfig \
zlib-dev zlib-static binutils-gold curl \
gcc g++ gmp-dev libc-dev libffi-dev make \
musl-dev ncurses-dev perl tar xz git

- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 'latest'

- name: Configure
run: cabal configure --enable-tests

- name: Freeze
run: cabal freeze --project-file=cabal.release.project

- uses: actions/cache@v4
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ runner.os }}-ghc-${{ matrix.ghc }}-

- name: Enable statically linked executables
run: |
echo 'executable-static: true' >> cabal.release.project

- name: Build
run: cabal build --project-file=cabal.release.project

- name: Test
run: cabal test --project-file=cabal.release.project all

- name: Tar cabal head executable
run: |
CONFER_EXEC=$(cabal list-bin --project-file=cabal.release.project confer:exe:confer)
DIR=$(dirname $CONFER_EXEC)
FILE=$(basename $CONFER_EXEC)
CONFER_EXEC_TAR=confer-head-${{ runner.os }}-x86_64.tar.gz
tar -czvf $CONFER_EXEC_TAR -C $DIR $FILE
echo CONFER_EXEC_TAR=$CONFER_EXEC_TAR >> $GITHUB_ENV

- name: Upload confer executable to workflow artifacts
uses: actions/upload-artifact@v3
with:
name: cabal-${{ runner.os }}-static-x86_64
path: ${{ env.CONFER_EXEC_TAR }}

prerelease-head:
name: Create a GitHub prerelease with the binary artifacts
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: ['tests', 'build-alpine']

steps:
- uses: actions/download-artifact@v3
with:
name: confer-Linux-x86_64

- uses: actions/download-artifact@v3
with:
name: confer-Linux-static-x86_64

- name: Create GitHub prerelease
uses: marvinpinto/[email protected]
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
automatic_release_tag: confer-head
prerelease: true
title: confer-head
files: |
confer-head-Linux-x86_64.tar.gz
confer-head-Linux-static-x86_64.tar.gz
27 changes: 14 additions & 13 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ on:
push:
branches: ["main"]

# jobs:
# fourmolu:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - uses: fourmolu/fourmolu-action@v10
# with:
# pattern: |
# src/**/*.hs
# test/**/*.hs
#
jobs:
fourmolu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: fourmolu/fourmolu-action@v10
with:
pattern: |
app/**/*.hs
src/**/*.hs
test/**/*.hs

hlint:
runs-on: ubuntu-latest
steps:
Expand All @@ -30,5 +31,5 @@ on:
- name: 'Run HLint'
uses: haskell-actions/hlint-run@v2
with:
path: '["src/", "test/"]'
path: '["app/", "src/", "test/"]'
fail-on: warning
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ tags
tags.mtime
.hpc
*.tix
*.local
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test: ## Run the test suite
@cabal test

lint: ## Run the code linter (HLint)
@find test src -name "*.hs" | xargs -P $(PROCS) -I {} hlint --refactor-options="-i" --refactor {}
@find app test src -name "*.hs" | xargs -P $(PROCS) -I {} hlint --refactor-options="-i" --refactor {}

style: ## Run the code styler (fourmolu and cabal-fmt)
@cabal-fmt -i *.cabal
Expand Down
5 changes: 1 addition & 4 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{-# LANGUAGE QuasiQuotes #-}

module Main where

import Control.Placeholder
import Data.Function ((&))
import Data.Map.Strict qualified as Map
import Effectful
Expand Down Expand Up @@ -96,4 +93,4 @@ withInfo :: Parser a -> String -> ParserInfo a
withInfo opts desc = info (helper <*> opts) $ progDesc desc

osPathOption :: ReadM OsPath
osPathOption = maybeReader (OsPath.encodeUtf)
osPathOption = maybeReader OsPath.encodeUtf
2 changes: 0 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ test-show-details: direct

documentation: True

optimization: 2

tests: True

-- package confer
Expand Down
14 changes: 14 additions & 0 deletions cabal.release.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import: cabal.project

optimization: 2

documentation: False

flags: -development

package *
ghc-options:
-flate-specialise -funbox-strict-fields
-finline-generics-aggressively -fexpose-all-unfoldings
-Wwarn=extended-warnings -fdicts-strict -fmax-worker-args=16
-fspec-constr-recursive=16 -funbox-strict-fields
13 changes: 0 additions & 13 deletions confer.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ extra-doc-files:
data-dir: runtime/lua
tested-with: GHC ==9.8.2

flag release
description: Compile the project for release
default: False
manual: True

flag development
description: Compile the project for development
default: True
Expand Down Expand Up @@ -54,14 +49,6 @@ common ghc-options
-fhide-source-paths -Wno-unused-do-bind -fshow-hole-constraints
-Wno-unticked-promoted-constructors

if flag(release)
ghc-options:
-flate-specialise -funbox-strict-fields
-finline-generics-aggressively -fexpose-all-unfoldings
-Werror=extended-warnings -fdicts-strict -fmax-worker-args=16
-fspec-constr-recursive=16 -funbox-strict-fields
-Wno-unused-packages -Werror=unused-imports

if flag(development)
ghc-options: -finfo-table-map -Wno-unused-imports -Wno-unused-packages

Expand Down
12 changes: 10 additions & 2 deletions src/Confer/Effect/Symlink.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import Control.Exception
import Control.Monad
import Control.Placeholder
import Data.Map.Strict (Map)
import Data.Map.Strict qualified as Map
import Data.Text (Text)
Expand All @@ -19,12 +18,12 @@
import Data.Text.Display
import Effectful
import Effectful.Dispatch.Dynamic
import Effectful.Error.Static (Error)

Check warning on line 21 in src/Confer/Effect/Symlink.hs

View workflow job for this annotation

GitHub Actions / 9.8.2 on ubuntu-latest

The import of ‘Effectful.Error.Static’ is redundant

Check warning on line 21 in src/Confer/Effect/Symlink.hs

View workflow job for this annotation

GitHub Actions / Build statically linked using alpine (9.8.2, ubuntu-latest)

The import of ‘Effectful.Error.Static’ is redundant
import Effectful.Error.Static qualified as Error
import Effectful.FileSystem
import Effectful.FileSystem qualified as FileSystem
import Effectful.State.Static.Local qualified as State
import System.Directory qualified as Directory

Check warning on line 26 in src/Confer/Effect/Symlink.hs

View workflow job for this annotation

GitHub Actions / 9.8.2 on ubuntu-latest

The qualified import of ‘System.Directory’ is redundant

Check warning on line 26 in src/Confer/Effect/Symlink.hs

View workflow job for this annotation

GitHub Actions / Build statically linked using alpine (9.8.2, ubuntu-latest)

The qualified import of ‘System.Directory’ is redundant
import System.Directory.Internal (FileType (..), OsPath)
import System.Directory.Internal qualified as Directory
import System.IO.Error
Expand Down Expand Up @@ -80,7 +79,16 @@
createFileLink sourcePath destinationPath
Directory ->
createDirectoryLink sourcePath destinationPath
DeleteSymlink _ -> todo
DeleteSymlink linkOsPath -> do
linkFilePath <- liftIO $ OsPath.decodeFS linkOsPath
sourceType <- liftIO $ do
metadata <- Directory.getFileMetadata linkOsPath
pure $ Directory.fileTypeFromMetadata metadata
case sourceType of
File ->
FileSystem.removeFile linkFilePath
Directory ->
FileSystem.removeDirectory linkFilePath
TestSymlink linkOsPath expectedLinkTarget -> do
linkFilepath <- liftIO $ OsPath.decodeFS linkOsPath
liftIO $
Expand Down
2 changes: 1 addition & 1 deletion test/Confer/CLI/Cmd/CheckTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ testNonSymlink =
Temporary.withSystemTempFile "confer-test.ext" $ \filepath _ -> do
result <- Symlink.runSymlinkIO $ do
osFilepath <- liftIO $ OsPath.encodeFS filepath
Symlink.testSymlink osFilepath ([osp| lol |])
Symlink.testSymlink osFilepath [osp| lol |]
assertIsNotSymlink result
Loading