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

feat: Add Haskell (Cabal) support #31434

Closed
wants to merge 2 commits into from
Closed
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
1 change: 1 addition & 0 deletions lib/constants/category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const Categories = [
'dotnet',
'elixir',
'golang',
'haskell',
'helm',
'iac',
'java',
Expand Down
2 changes: 2 additions & 0 deletions lib/modules/datasource/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { GlasskubePackagesDatasource } from './glasskube-packages';
import { GoDatasource } from './go';
import { GolangVersionDatasource } from './golang-version';
import { GradleVersionDatasource } from './gradle-version';
import { HackageDatasource } from './hackage';
import { HelmDatasource } from './helm';
import { HermitDatasource } from './hermit';
import { HexDatasource } from './hex';
Expand Down Expand Up @@ -111,6 +112,7 @@ api.set(GlasskubePackagesDatasource.id, new GlasskubePackagesDatasource());
api.set(GoDatasource.id, new GoDatasource());
api.set(GolangVersionDatasource.id, new GolangVersionDatasource());
api.set(GradleVersionDatasource.id, new GradleVersionDatasource());
api.set(HackageDatasource.id, new HackageDatasource());
api.set(HelmDatasource.id, new HelmDatasource());
api.set(HermitDatasource.id, new HermitDatasource());
api.set(HexDatasource.id, new HexDatasource());
Expand Down
34 changes: 34 additions & 0 deletions lib/modules/datasource/hackage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Http } from '../../../util/http';
import { logger } from '../../../logger';
import { Datasource } from '../datasource';
import type {
//DigestConfig,
GetReleasesConfig,
Release,
ReleaseResult,
} from '../types';

export class HackageDatasource extends Datasource {
static readonly id = 'hackage';

constructor() {
super(HackageDatasource.id);
}

async getReleases(config: GetReleasesConfig): Promise<ReleaseResult> {
const releases = [];
const res = await new Http('any').getJson('https://hackage.haskell.org/package/' + config.packageName + '.json');
const versions = Object.keys(res.body as object);
for (let version of versions) {
logger.info({version}, 'hackage:getReleases');
const release: Release =
{ version
, releaseTimestamp: null
, isStable: true
, changelogUrl: 'https://hackage.haskell.org/package/' + config.packageName + "-" + version + "/changelog"
};
releases.push(release);
}
return {releases};
}
}
2 changes: 2 additions & 0 deletions lib/modules/manager/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import * as gleam from './gleam';
import * as gomod from './gomod';
import * as gradle from './gradle';
import * as gradleWrapper from './gradle-wrapper';
import * as haskellCabal from './haskell-cabal';
import * as helmRequirements from './helm-requirements';
import * as helmValues from './helm-values';
import * as helmfile from './helmfile';
Expand Down Expand Up @@ -146,6 +147,7 @@ api.set('gleam', gleam);
api.set('gomod', gomod);
api.set('gradle', gradle);
api.set('gradle-wrapper', gradleWrapper);
api.set('haskell-cabal', haskellCabal);
api.set('helm-requirements', helmRequirements);
api.set('helm-values', helmValues);
api.set('helmfile', helmfile);
Expand Down
44 changes: 44 additions & 0 deletions lib/modules/manager/haskell-cabal/__fixtures__/Octree-0.5.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Octree
version: 0.5
stability: beta
homepage: https://github.com/mgajda/octree
package-url: http://hackage.haskell.org/package/octree
synopsis: Simple unbalanced Octree for storing data about 3D points
description: Octree data structure is relatively shallow data structure for space partitioning.
category: Data
license: BSD3
license-file: LICENSE

author: Michal J. Gajda
copyright: Copyright by Michal J. Gajda '2012
maintainer: [email protected]
bug-reports: mailto:[email protected]


build-type: Simple
cabal-version: >=1.8
tested-with: GHC==7.0.4,GHC==7.4.1,GHC==7.4.2,GHC==7.6.0

source-repository head
type: git
location: [email protected]:mgajda/octree.git

Library
build-depends: base>=4.0 && < 4.7, AC-Vector >= 2.3.0, QuickCheck >= 2.4.0
exposed-modules: Data.Octree
other-modules: Data.Octree.Internal
exposed: True
extensions: ScopedTypeVariables

Test-suite test_Octree
Type: exitcode-stdio-1.0
Build-depends: base>=4.0 && < 4.7, AC-Vector >= 2.3.0, QuickCheck >= 2.4.0
Main-is: tests/test_Octree.hs

Test-suite readme
  type: exitcode-stdio-1.0
-- We have a symlink: README.lhs -> README.md
  main-is: README.lhs
Build-depends: base>=4.0 && < 4.7, AC-Vector >= 2.3.0, QuickCheck >= 2.4.0, markdown-unlit
  ghc-options: -pgmL markdown-unlit

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
cabal-version: 3.0
name: all-upper-bound
version: 0
synopsis: all-upper-bound
category: Tests
license: MIT
maintainer: [email protected]
description: all-upper-bound test package.

library
default-language: Haskell2010
build-depends:
, base ^>=4.14
, somelib
, alphalib
, betalib
, deltalib

exposed-modules: Foo
10 changes: 10 additions & 0 deletions lib/modules/manager/haskell-cabal/__fixtures__/anynone.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cabal-version: 3.0
name: anynone
version: 0
synopsis: The -any none demo
build-type: Simple

library
default-language: Haskell2010
exposed-modules: AnyNone
build-depends: base -any
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cabal-version: 1.12
name: assoc
version: 1.1
license: BSD3
license-file: LICENSE
synopsis: swap and assoc: Symmetric and Semigroupy Bifunctors
category: Data
description:
Provides generalisations of
@swap :: (a,b) -> (b,a)@ and
@assoc :: ((a,b),c) -> (a,(b,c))@
to
@Bifunctor@s supporting similar operations (e.g. @Either@, @These@).

author: Oleg Grenrus <[email protected]>
maintainer: Oleg Grenrus <[email protected]>
build-type: Simple
tested-with:
GHC ==7.0.4
|| ==7.2.2
|| ==7.4.2
|| ==7.6.3
|| ==7.8.4
|| ==7.10.3
|| ==8.0.2
|| ==8.2.2
|| ==8.4.4
|| ==8.6.5
|| ==8.8.1

source-repository head
type: git
location: https://github.com/phadej/assoc.git

library
default-language: Haskell2010
hs-source-dirs: src
build-depends:
base >=4.3 && <4.13
, bifunctors >=5.5.4 && <5.6

cpp-options: -traditional

exposed-modules:
Data.Bifunctor.Assoc
Data.Bifunctor.Swap

other-extensions: TypeFamilies
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cabal-version: 2.2
category: test
description: test a build check involving C++-options field
license: BSD-3-Clause
maintainer: [email protected]
name: cxx-options-with-optimization
synopsis: test a build check
version: 1

library
build-depends: base >= 4.9 && <4.10
cc-options: -O2
default-language: Haskell2010
exposed-modules: Prelude
hs-source-dirs: .
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cabal-version: 3.0
name: common-conditional
version: 0
synopsis: Common-stanza demo demo
build-type: Simple

source-repository head
Type: git
Location: https://github.com/hvr/-.git

flag foo
manual: True
default: True

common win-dows
if os(windows)
build-depends: Win32

common deps
import: win-dows
buildable: True
build-depends:
base >=4.10 && <4.11,
containers

library
if flag(foo)
import: deps

default-language: Haskell2010
exposed-modules: ElseIf

build-depends:
ghc-prim

test-suite tests
-- buildable fields verify that we don't have duplicate field warnings
buildable: True
if os(windows)
buildable: False

if flag(foo)
import: deps, win-dows

type: exitcode-stdio-1.0
main-is: Tests.hs

build-depends:
HUnit
35 changes: 35 additions & 0 deletions lib/modules/manager/haskell-cabal/__fixtures__/common.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: common
version: 0
x-revision: 1
synopsis: Common-stanza demo demo
build-type: Simple
cabal-version: >=1.10
-- note: empty field
x-follows-version-policy:

source-repository head
Type: git
Location: https://github.com/hvr/-.git

common deps
build-depends:
base >=4.10 && <4.11,
containers

library
import: deps

default-language: Haskell2010
exposed-modules: "ElseIf"

build-depends:
ghc-prim

test-suite tests
import: deps

type: exitcode-stdio-1.0
main-is: Tests.hs

build-depends:
HUnit
53 changes: 53 additions & 0 deletions lib/modules/manager/haskell-cabal/__fixtures__/common2.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cabal-version: 2.2
name: common
version: 0
synopsis: Common-stanza demo demo
build-type: Simple

source-repository head
Type: git
Location: https://github.com/hvr/-.git

common win-dows
if os(windows)
build-depends: Win32

common deps
import: win-dows
buildable: True
build-depends:
base >=4.10 && <4.11,
containers

library
import: deps

default-language: Haskell2010
exposed-modules: ElseIf

build-depends:
ghc-prim

-- .expr should show libVisible: False
library internal
import: deps

default-language: Haskell2010
exposed-modules: ElseIf2

build-depends:
ghc-prim

test-suite tests
import: deps, win-dows

-- buildable fields verify that we don't have duplicate field warnings
buildable: True
if os(windows)
buildable: False

type: exitcode-stdio-1.0
main-is: Tests.hs

build-depends:
HUnit
36 changes: 36 additions & 0 deletions lib/modules/manager/haskell-cabal/__fixtures__/common3.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cabal-version: 2.2
name: common
version: 0
x-revision: 1
synopsis: Common-stanza demo demo
build-type: Simple
-- note: empty field
x-follows-version-policy:

source-repository head
Type: git
Location: https://github.com/hvr/-.git

common deps
build-depends:
base >=4.10 && <4.11,
containers

library
default-language: Haskell2010
exposed-modules: "ElseIf"

-- not first: will be omitted and generate warning
import: deps

build-depends:
ghc-prim

test-suite tests
import: deps

type: exitcode-stdio-1.0
main-is: Tests.hs

build-depends:
HUnit
Loading