Skip to content

Commit

Permalink
add first draft of cabal parsing service
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Brandt committed Jan 12, 2018
1 parent cd36cef commit 51d0340
Show file tree
Hide file tree
Showing 19 changed files with 566 additions and 15 deletions.
26 changes: 26 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Created by https://www.gitignore.io/api/haskell

### Haskell ###
dist
!dist/build/cabal-parser/cabal-parser
dist-*
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
.HTF/

# End of https://www.gitignore.io/api/haskell
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Created by https://www.gitignore.io/api/haskell

### Haskell ###
dist
dist-*
cabal-dev
*.o
*.hi
*.chi
*.chs.h
*.dyn_o
*.dyn_hi
.hpc
.hsenv
.cabal-sandbox/
cabal.sandbox.config
*.prof
*.aux
*.hp
*.eventlog
.stack-work/
cabal.project.local
.HTF/

# End of https://www.gitignore.io/api/haskell
88 changes: 88 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# This Travis job script has been generated by a script via
#
# make_travis_yml_2.hs 'cabal-parser.cabal'
#
# For more information, see https://github.com/hvr/multi-ghc-travis
#
language: c
sudo: false

git:
submodules: false # whether to recursively clone submodules

cache:
directories:
- $HOME/.cabal/packages
- $HOME/.cabal/store

before_cache:
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
# remove files that are regenerated by 'cabal update'
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
- rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx

matrix:
include:
- compiler: "ghc-8.0.1"
# env: TEST=--disable-tests BENCH=--disable-benchmarks
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.1], sources: [hvr-ghc]}}
- compiler: "ghc-8.0.2"
# env: TEST=--disable-tests BENCH=--disable-benchmarks
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
- compiler: "ghc-8.2.1"
# env: TEST=--disable-tests BENCH=--disable-benchmarks
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
- compiler: "ghc-head"
# env: TEST=--disable-tests BENCH=--disable-benchmarks
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-head], sources: [hvr-ghc]}}

allow_failures:
- compiler: "ghc-head"

before_install:
- HC=${CC}
- unset CC
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
- PKGNAME='cabal-parser'

install:
- cabal --version
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
- BENCH=${BENCH---enable-benchmarks}
- TEST=${TEST---enable-tests}
- travis_retry cabal update -v
- sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
- rm -fv cabal.project.local
- "echo 'packages: .' > cabal.project"
- rm -f cabal.project.freeze
- cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all

# Here starts the actual work to be performed for the package under test;
# any command which exits with a non-zero exit code causes the build to fail.
script:
- if [ -f configure.ac ]; then autoreconf -i; fi
- rm -rf .ghc.environment.* dist/
- cabal sdist # test that a source-distribution can be generated
- cd dist/
- SRCTAR=(${PKGNAME}-*.tar.gz)
- SRC_BASENAME="${SRCTAR/%.tar.gz}"
- tar -xvf "./$SRC_BASENAME.tar.gz"
- cd "$SRC_BASENAME/"
## from here on, CWD is inside the extracted source-tarball
- rm -fv cabal.project.local
- "echo 'packages: .' > cabal.project"
# this builds all libraries and executables (without tests/benchmarks)
- rm -f cabal.project.freeze
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
# this builds all libraries and executables (including tests/benchmarks)
# - rm -rf ./dist-newstyle

# build & run tests
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi

# EOF
74 changes: 74 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM alpine:3.7
MAINTAINER Alex Brandt <[email protected]>

RUN apk add --no-cache musl-dev zlib-dev
RUN apk add --no-cache cabal ghc

RUN cabal update

WORKDIR /usr/local/src/cabal-parser

COPY ./cabal-parser.cabal /usr/local/src/cabal-parser/cabal-parser.cabal
RUN cabal install -j --only-dependencies

COPY . /usr/local/src/cabal-parser
RUN cabal build -j --ghc-options="-static -optc-static -optl-static -optl-pthread"

FROM alpine:3.7
MAINTAINER Alex Brandt <[email protected]>

RUN apk add --no-cache ca-certificates

COPY --from=0 /usr/local/src/cabal-parser/dist/build/cabal-parser/cabal-parser /

ENTRYPOINT [ "/cabal-parser" ]
CMD [ "Heroku Compatability" ]
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Description

Tiny Web Service for Parsing Cabal Files

Helper service for bibliothecary to parse cabal files from various sources.
Provides a fiat JSON represenation for a given cabal file posted to this HTTP API.

# Getting Started

Developer documentation can be generated with:

```bash
cabal haddock --executables
```

Once the documentation is generated, it is available at:
`./dist/doc/html/cabal-parser/cabal-parser/index.html`.

## Locally with [`docker-compose`][docker-compose]

This project is setup to run with [`docker-compose`][docker-compose]. Running
the following command will build a [docker] image (includes building
cabal-parser), and start all requisite services as [docker] containers.

```bash
docker-compose up -d
```

cabal-parser will be available at <http://localhost:PORT> once this
command finishes executing. You can get `PORT` from `docker ps`.

## Locally with [`nix-shell`][nix-shell]

This project is setup with [`nix-shell`][nix-shell]. Running the following
command will build a local development environment where all of the
supplementary tools are pre-installed.

```bash
nix-env -i cabal
nix-shell
```

Once this command finishes executing, the libraries and other tools are
available. You will still need to have cabal installed another way.

## Others

This project utilizes [`cabal`][cabal] like most [Haskell] projects and the
standard [Haskell] development environment for your platform should work just
fine.

[cabal]: https://www.haskell.org/cabal/
[docker-compose]: https://docs.docker.com/compose/
[docker]: https://docs.docker.com/
[Haskell]: https://www.haskell.org/
[nix-shell]: https://nixos.org/nix/manual/#sec-nix-shell
61 changes: 48 additions & 13 deletions cabal-parser.cabal
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
-- Initial cabal-parser.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/

name: cabal-parser
version: 0.1.0.0
synopsis: Cabal Parser for Libraries.io's bibliothecary
-- description:
synopsis: Tiny Web Service for Parsing Cabal Files

description:
Helper service for bibliothecary to parse cabal files from various sources.
Provides a fiat JSON represenation for a given cabal file posted to this HTTP API.

homepage: https://github.com/alunduil/librariesio-cabal-parser
bug-reports: https://github.com/alunduil/librariesio-cabal-parser/issues
license: GPL-3
license-file: LICENSE
author: Alex Brandt
maintainer: [email protected]
-- copyright:
copyright: (c) 2018 Alex Brandt
category: Development
build-type: Simple
extra-source-files: ChangeLog.md
cabal-version: >=1.10
cabal-version: >= 1.10
tested-with: GHC == 8.*

extra-source-files:
ChangeLog.md
, LICENSE
, README.md
, Setup.hs

source-repository head
type: git
location: https://github.com/alunduil/librariesio-cabal-parser
branch: develop

executable cabal-parser
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >=4.9 && <4.10
hs-source-dirs: src
default-language: Haskell2010
main-is: Main.hs

ghc-options: -Wall -fwarn-tabs -fwarn-monomorphism-restriction
-fwarn-unused-do-bind

hs-source-dirs:
src

other-modules:
API
, Dependency
, Distribution.Types.PackageDescription.MimeUnrender
, Distribution.Types.PackageName.JSON
, Distribution.Version.JSON
, Environment

build-depends:
aeson == 1.1.*
, base >= 4.9 && < 4.10
, Cabal == 2.0.*
, envy == 1.3.*
, servant-server == 0.11.*
, text == 1.2.*
, utf8-string == 1.0.*
, warp == 3.2.*

other-extensions:
21 changes: 21 additions & 0 deletions cabal-parser.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
let
config = {
packageOverrides = pkgs: rec {
haskellPackages = pkgs.haskellPackages.override {
overrides = haskellPackagesNew: haskellPackagesOld: rec {

Cabal =
haskellPackagesNew.callPackage ./cabal.nix { };

cabal-parser =
haskellPackagesNew.callPackage ./default.nix { };

};
};
};
};

pkgs = import <nixpkgs> { inherit config; };
in
{ cabal-parser = pkgs.haskellPackages.cabal-parser;
}
Loading

0 comments on commit 51d0340

Please sign in to comment.