Skip to content

Commit 2be2501

Browse files
committed
add proto-lens
1 parent 5746421 commit 2be2501

File tree

220 files changed

+33004
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

220 files changed

+33004
-0
lines changed
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Stack CI
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
pull_request:
22+
types:
23+
- opened
24+
- reopened
25+
- synchronize
26+
27+
# Cancel earlier runs for pushes to the same branch or updates to the same PR.
28+
concurrency:
29+
group: ci-${{ github.ref }}
30+
cancel-in-progress: true
31+
32+
jobs:
33+
prepare:
34+
name: Determine Build Matrix
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 2
37+
38+
outputs:
39+
ci-builds: ${{ steps.read-builds.outputs.ci-builds }}
40+
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
44+
with:
45+
submodules: true
46+
47+
- name: Read matrix.yaml
48+
id: read-builds
49+
run: |
50+
cat matrix.yaml
51+
CI_BUILDS=$(yq eval -o json -I 0 matrix.yaml)
52+
echo "::set-output name=ci-builds::$CI_BUILDS"
53+
54+
build:
55+
name: Build and Test
56+
runs-on: ubuntu-latest
57+
needs: prepare
58+
timeout-minutes: 45
59+
60+
strategy:
61+
fail-fast: false
62+
matrix: ${{ fromJson(needs.prepare.outputs.ci-builds) }}
63+
64+
env:
65+
STACK: "stack --stack-yaml ${{ matrix.build.stackyaml }} --lock-file read-write --resolver ${{ matrix.build.resolver }} --compiler ${{ matrix.build.compiler }}"
66+
67+
ghc-cache-ver: v1
68+
dep-cache-ver: v1
69+
mod-cache-ver: v1
70+
71+
steps:
72+
- name: Checkout
73+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
74+
with:
75+
submodules: true
76+
77+
# Installs the recent protoc, for now unpinned to gain some experience
78+
- name: Install Protoc
79+
uses: arduino/setup-protoc@v1
80+
with:
81+
version: '3.x'
82+
83+
# Install Stack without GHC first, so we have an opportunity to cache the
84+
# Pantry package index.
85+
- name: Install Stack
86+
uses: haskell/actions/setup@eb3073b623d53d0cdd38e4d4c2408f14e3fc71c5
87+
id: setup-stack
88+
with:
89+
enable-stack: true
90+
stack-no-global: true
91+
92+
# The cache key for the Pantry package index.
93+
- name: Fetch Hackage Stamp
94+
run: curl -O https://hackage.haskell.org/timestamp.json
95+
96+
# Try to avoid rebuilding the whole Pantry index, since it takes over a
97+
# minute to parse and index all the Cabal files on Hackage from scratch.
98+
#
99+
# Pantry will try to incrementally extend its index if it gets an
100+
# out-of-date one, so we benefit from using restore-keys to bootstrap it
101+
# with a previous index.
102+
- name: Cache Pantry Package Index
103+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
104+
with:
105+
# Everything except the decompressed Hackage index tarball. Why is
106+
# that even materialized to disk?
107+
path: |
108+
${{ steps.setup-stack.outputs.stack-root }}/pantry/pantry*
109+
${{ steps.setup-stack.outputs.stack-root }}/pantry/hackage/*
110+
!${{ steps.setup-stack.outputs.stack-root }}/pantry/hackage/*.tar
111+
!${{ steps.setup-stack.outputs.stack-root }}/pantry/hackage/*.tar.gz
112+
key: ${{ runner.os }}-${{ matrix.build.compiler }}-${{ hashFiles('timestamp.json') }}
113+
restore-keys: |
114+
${{ runner.os }}-${{ matrix.build.compiler }}-
115+
${{ runner.os }}-
116+
117+
# GHC takes a while to gunzip and configure; let's try caching it
118+
# pre-configured with zstd.
119+
- name: Cache Configured GHC
120+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
121+
with:
122+
# Omit the tarball itself; it'll double the cache size assuming
123+
# similar compression ratios.
124+
path: |
125+
${{ steps.setup-stack.outputs.stack-root }}/programs/*/*
126+
!${{ steps.setup-stack.outputs.stack-root }}/programs/*/*.tar.xz
127+
key: ${{ env.ghc-cache-ver}}-${{ runner.os }}-${{ matrix.build.compiler }}
128+
129+
# Now do stack setup, which should do as little cabal-file-indexing work
130+
# as possible.
131+
- name: Pre-install GHC with Stack
132+
run: $STACK setup
133+
134+
# Have stack construct a build plan and lock file for use as a cache key.
135+
- name: Determine Build Plan
136+
run: |
137+
$STACK build --test --dry-run
138+
echo Lock files:
139+
echo stack*.lock ${{ hashFiles('stack*.lock') }}
140+
141+
# Cache pre-built dependencies from the same lock file; restore from
142+
# other builds with the same GHC version to benefit from any packages in
143+
# common between two lockfiles.
144+
- name: Cache Dependencies
145+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
146+
with:
147+
# The Stack global work directory, minus GHC installations (already
148+
# extracted from a tarball) and the Pantry package index (already
149+
# cached).
150+
#
151+
# Excluding subdirectories of an included directory doesn't work, so
152+
# glob everything inside $STACK_ROOT and then exclude the
153+
# subdirectories we don't want.
154+
path: |
155+
${{ steps.setup-stack.outputs.stack-root }}/*
156+
!${{ steps.setup-stack.outputs.stack-root }}/programs
157+
!${{ steps.setup-stack.outputs.stack-root }}/pantry
158+
key: ${{ env.dep-cache-ver }}-${{ runner.os }}-${{ matrix.build.compiler }}-${{ hashFiles('stack*.lock') }}
159+
restore-keys: |
160+
${{ env.dep-cache-ver }}-${{ runner.os }}-${{ matrix.build.compiler }}-
161+
162+
# We just overwrote some Stack internal files with a cached version that
163+
# has an older timestamp for the GHC binary, which will confuse it on the
164+
# next command. Quarantine the warnings in their own step for
165+
# aesthetics, even though they wouldn't be harmful if we just let them
166+
# happen in the next build step.
167+
- name: Refresh GHC Metadata
168+
run: |
169+
echo "Re-running setup to let Stack update GHC's timestamp."
170+
echo "A warning about mismatched GHC metadata is expected."
171+
echo
172+
$STACK setup
173+
174+
# Build the dependencies, hopefully doing little to no work.
175+
- name: Build Dependencies
176+
run: $STACK build --test --only-dependencies
177+
178+
# Cache pre-built modules for incremental builds, making sure to keep
179+
# builds with different dependencies separate.
180+
- name: Cache Modules
181+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
182+
with:
183+
path: "**/.stack-work"
184+
key: |
185+
${{ env.mod-cache-ver }}-${{ runner.os }}-${{ matrix.build.compiler }}-${{ hashFiles('stack*.lock') }}-${{hashFiles('**/*.hs', '**/package.yaml') }}
186+
restore-keys: |
187+
${{ env.mod-cache-ver }}-${{ runner.os }}-${{ matrix.build.compiler }}-${{ hashFiles('stack*.lock') }}-
188+
${{ env.mod-cache-ver }}-${{ runner.os }}-${{ matrix.build.compiler }}-
189+
190+
# Build, Haddock, and test, taking care to build in only one
191+
# configuration to make caching work as well as possible. In practice,
192+
# this means building modules, tests, and documentation all at once, then
193+
# running tests under the same configuration afterwards. Separating them
194+
# isn't crucial; it's just to make the CI results easier to understand.
195+
#
196+
# Using --no-haddock-deps somehow forces it to rebuild from scratch every
197+
# time, so leave that out -- rebuilding unconditionally seems worse than
198+
# building (and caching) dependencies' haddock.
199+
- name: Build
200+
run: $STACK build --test --no-run-tests
201+
202+
# Run tests with concurrency disabled; see
203+
# https://github.com/commercialhaskell/stack/issues/5024.
204+
- name: Test
205+
run: $STACK build --test -j 1
206+
207+
- name: Haddock
208+
run: $STACK build --haddock --test --no-run-tests

pub/proto-lens/.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.stack-work/
2+
dist/
3+
# Generated automatically by stack:
4+
*.yaml.lock
5+
# For "cabal sandbox"
6+
.cabal-sandbox
7+
cabal.sandbox.config
8+
dist-newstyle/
9+
result

pub/proto-lens/.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "google/protobuf"]
2+
path = google/protobuf
3+
url = https://github.com/google/protobuf

pub/proto-lens/.travis.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Use a lightweight base image; we provide our own build tools.
2+
language: c
3+
4+
# Docker builds make GHC much slower for some reason:
5+
# https://github.com/travis-ci/travis-ci/issues/5623
6+
sudo: true
7+
8+
cache:
9+
timeout: 600 # 10 minutes
10+
directories:
11+
- $HOME/.ghc
12+
- $HOME/.stack
13+
- $HOME/.cabal
14+
15+
matrix:
16+
include:
17+
- env: BUILD=cabal GHCVER=8.4.4 CABALVER=2.2
18+
addons: {apt: {packages: [cabal-install-2.2, ghc-8.4.4], sources: [hvr-ghc]}}
19+
- env: BUILD=cabal GHCVER=8.6.5 CABALVER=2.4
20+
addons: {apt: {packages: [cabal-install-2.4, ghc-8.6.5], sources: [hvr-ghc]}}
21+
# TODO: switch everything to cabal new-build
22+
- env: BUILD=cabal-new GHCVER=8.6.5 CABALVER=2.4
23+
addons: {apt: {packages: [cabal-install-2.4, ghc-8.6.5], sources: [hvr-ghc]}}
24+
- env: BUILD=stack STACK='stack --resolver=lts-12.26'
25+
addons: {apt: {packages: [libgmp-dev]}}
26+
- env: BUILD=stack STACK='stack' # Use the resolver in stack.yaml
27+
addons: {apt: {packages: [libgmp-dev]}}
28+
- env: BUILD=stack STACK='stack --stack-yaml=stack-8.8.yaml'
29+
addons: {apt: {packages: [libgmp-dev]}}
30+
- env: BUILD=stack STACK='stack --stack-yaml=stack-8.10.yaml'
31+
addons: {apt: {packages: [libgmp-dev]}}
32+
- env: BUILD=stack STACK='stack --stack-yaml=stack-9.0.yaml'
33+
addons: {apt: {packages: [libgmp-dev]}}
34+
35+
before_install:
36+
- mkdir -p $HOME/.local/bin
37+
- case "$BUILD" in
38+
stack)
39+
export PATH=/opt/ghc/$GHCVER/bin:$HOME/.local/bin:$PATH;;
40+
cabal)
41+
export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:$HOME/.cabal/bin:$PATH;;
42+
cabal-new)
43+
export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$HOME/.local/bin:$HOME/.cabal/bin:$PATH;;
44+
esac
45+
- curl -L https://github.com/commercialhaskell/stack/releases/download/v2.3.1/stack-2.3.1-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C $HOME/.local/bin '*/stack'
46+
- curl -L https://github.com/protocolbuffers/protobuf/releases/download/v3.14.0/protoc-3.14.0-linux-x86_64.zip > protoc-release.zip
47+
- unzip -p protoc-release.zip bin/protoc > $HOME/.local/bin/protoc
48+
- chmod a+x $HOME/.local/bin/protoc
49+
- rm protoc-release.zip
50+
51+
install:
52+
- case "$BUILD" in
53+
stack)
54+
$STACK setup --no-terminal;
55+
$STACK build --no-terminal happy;
56+
$STACK build --only-dependencies --no-terminal;;
57+
cabal)
58+
cabal update;;
59+
esac
60+
61+
script:
62+
# Separate stack's build and test commands, since build by itself hits some
63+
# edge cases around custom Setup.hs script dependencies.
64+
# Also build the tutorial, with proto-lens-* as extra-deps. Note that
65+
# since stack is not hermetic, the extra-deps for the tutorial reuse some
66+
# build outputs from the regular build.
67+
- case "$BUILD" in
68+
stack)
69+
STACK_ARGS=(--haddock --no-haddock-deps);
70+
$STACK build --bench --no-run-benchmarks "${STACK_ARGS[@]}" && $STACK test "${STACK_ARGS[@]}" &&
71+
(cd proto-lens-tutorial && $STACK build "${STACK_ARGS[@]}");;
72+
cabal)
73+
./travis-cabal.sh;;
74+
cabal-new)
75+
./travis-cabal-new.sh;;
76+
esac

pub/proto-lens/CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing
2+
3+
Want to contribute? Great! First, read this page (including the small print at the end).
4+
5+
### Before you contribute
6+
Before we can use your code, you must sign the
7+
[Google Individual Contributor License Agreement](https://cla.developers.google.com/about/google-individual)
8+
(CLA), which you can do online. The CLA is necessary mainly because you own the
9+
copyright to your changes, even after your contribution becomes part of our
10+
codebase, so we need your permission to use and distribute your code. We also
11+
need to be sure of various other things—for instance that you'll tell us if you
12+
know that your code infringes on other people's patents. You don't have to sign
13+
the CLA until after you've submitted your code for review and a member has
14+
approved it, but you must do it before we can put your code into our codebase.
15+
Before you start working on a larger contribution, you should get in touch with
16+
us first through the issue tracker with your idea so that we can help out and
17+
possibly guide you. Coordinating up front makes it much easier to avoid
18+
frustration later on.
19+
20+
### Code reviews
21+
All submissions, including submissions by project members, require review. We
22+
use Github pull requests for this purpose.
23+
24+
### The small print
25+
Contributions made by corporations are covered by a different agreement than
26+
the one above, the
27+
[Software Grant and Corporate Contributor License Agreement](https://cla.developers.google.com/about/google-corporate).

pub/proto-lens/LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright (c) 2016, Google Inc.
2+
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Google Inc. nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)