Skip to content

Commit

Permalink
CI: Build, Lint and test
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthi-chaud committed Jun 30, 2024
1 parent 06af52b commit 865cfc1
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Cache'
description: 'Cache for CI'
runs:
using: "composite"
steps:
- uses: actions/cache@v3
name: Cache ~/.stack
with:
path: ~/.stack
key: stack-global
restore-keys: |
stack-global
- uses: actions/cache@v3
name: Cache .stack-work
with:
path: ./.stack-work
key: stack-work
restore-keys: |
stack-work
- name: Install Stack
shell: bash
run: curl -sSL https://get.haskellstack.org/ | sh -s - -f
87 changes: 87 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: "CI for haskell-ffprobe"
on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
release:
types: [ published ]

defaults:
run:
shell: bash

jobs:
Changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
sources: ${{ steps.filter.outputs.sources }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
sources:
- 'src/**'
- 'test/**.hs'
- '.github/workflows/CI.yml'
Build:
needs: changes
if: ${{ needs.changes.outputs.sources == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup GHC
uses: ./.github/actions/cache
- name: Build
run: stack build
Format:
if: ${{ needs.changes.outputs.sources == 'true' }}
runs-on: ubuntu-latest
needs: [ Build ]
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup GHC
uses: ./.github/actions/cache
- uses: haskell-actions/run-fourmolu@v9
with:
version: "0.14.0.0"
pattern: |
./src/**/*.hs
./test/**/*.hs
follow-symbolic-links: false
Lint:
if: ${{ needs.changes.outputs.sources == 'true' }}
runs-on: ubuntu-latest
needs: [ Build ]
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup GHC
uses: ./.github/actions/cache
- name: 'Set up HLint'
uses: rwe/actions-hlint-setup@v1
with:
version: '3.5'
- name: 'Run HLint'
uses: rwe/actions-hlint-run@v2
with:
path: '["./src/", "./test/"]'
fail-on: warning
Tests:
runs-on: ubuntu-latest
needs: [ Build ]
if: ${{ needs.changes.outputs.sources == 'true' }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Setup GHC
uses: ./.github/actions/cache
- name: Run unit tests
run: stack test
2 changes: 1 addition & 1 deletion test/FFProbe/Data/TestChapter.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ specs = describe "Chapter Parsing" $ do
shouldBeRight
(eitherDecodeStrict rawJson)
( \chapter -> do
id chapter `shouldBe` 8
FFProbe.Data.Chapter.id chapter `shouldBe` 8
timeBase chapter `shouldBe` "1/1000000000"
startTime chapter `shouldBe` 0.0
endTime chapter `shouldBe` 117.56
Expand Down

0 comments on commit 865cfc1

Please sign in to comment.