-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
406 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: "Haddock documentation" | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ghc: ["8.10.2"] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Select build directory | ||
run: | | ||
CABAL_BUILDDIR=dist | ||
echo "CABAL_BUILDDIR=$CABAL_BUILDDIR" | ||
echo "CABAL_BUILDDIR=$CABAL_BUILDDIR" >> $GITHUB_ENV | ||
- name: Set cache version | ||
run: echo "CACHE_VERSION=grFfw8r" >> $GITHUB_ENV | ||
|
||
- name: Add build script path | ||
run: echo "$(pwd)/.github/bin" >> $GITHUB_PATH | ||
|
||
- name: Configure to use libsodium | ||
run: | | ||
cat >> cabal.project <<EOF | ||
package cardano-crypto-praos | ||
flags: -external-libsodium-vrf | ||
EOF | ||
- uses: haskell/actions/setup@v1 | ||
id: setup-haskell | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
cabal-version: 3.4.0.0-rc4 | ||
|
||
- name: Haskell versions | ||
run: | | ||
ghc --version | ||
cabal --version | ||
- name: Install build environment | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get -y install libsodium23 libsodium-dev | ||
sudo apt-get -y install libsystemd0 libsystemd-dev | ||
sudo apt-get -y remove --purge software-properties-common | ||
sudo apt-get -y autoremove | ||
- name: Cabal update | ||
run: cabal update | ||
|
||
- name: Cabal Configure | ||
run: cabal configure --builddir="$CABAL_BUILDDIR" --write-ghc-environment-files=always | ||
|
||
- name: Record dependencies | ||
run: | | ||
cat ${{ env.PLAN_JSON }} | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt | ||
- uses: actions/cache@v2 | ||
name: Cache cabal store | ||
with: | ||
path: ${{ steps.setup-haskell.outputs.cabal-store }} | ||
key: cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} | ||
restore-keys: | | ||
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }} | ||
cache-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}- | ||
- name: Install dependencies | ||
run: cabal build all --builddir="$CABAL_BUILDDIR" --only-dependencies | ||
|
||
- name: Use cabal.project.local.github-pages | ||
run: | | ||
cat ./cabal.project.local.github-pages >> ./cabal.project.local | ||
cat ./cabal.project.local | ||
- name: build Haddock documentation 🔧 | ||
run: | | ||
mkdir ./haddocks | ||
./scripts/haddocs.sh ./haddocks true "$CABAL_BUILDDIR" | ||
- uses: actions/upload-artifact@v2 | ||
if: ${{ always() }} | ||
continue-on-error: true | ||
with: | ||
name: haddocks-${{ matrix.os }}-${{ matrix.ghc }} | ||
path: ./haddocks | ||
|
||
- name: deploy to gh-pages 🚀 | ||
run: | | ||
git fetch origin gh-pages:gh-pages | ||
git checkout gh-pages | ||
cp -r ./haddocks/* ./ | ||
rm -rf haddocks | ||
git add -A | ||
git commit -m "Deployed haddocks" || true | ||
git push https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git HEAD:gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,7 @@ tmp | |
logs | ||
/chairman/db | ||
/html | ||
|
||
# Ignore files generated by haddock | ||
/haddocks | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package cardano-crypto-praos | ||
flags: -external-libsodium-vrf | ||
|
||
tests: False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
name: "Haddock documentation" | ||
|
||
on: | ||
push: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
jobs: | ||
haddocks: | ||
name: "Haddocks" | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
ghc: ["8.10.2"] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
|
||
- name: Select build directory | ||
run: | | ||
if [ "$OS" == Windows_NT ]; then | ||
CABAL_BUILDDIR="D:\\a\\_temp\\dist" | ||
else | ||
CABAL_BUILDDIR="dist-newstyle" | ||
fi | ||
echo "CABAL_BUILDDIR=$CABAL_BUILDDIR" | ||
echo "CABAL_BUILDDIR=$CABAL_BUILDDIR" >> $GITHUB_ENV | ||
- name: Install pkgconfiglite | ||
if: matrix.os == 'windows-latest' | ||
run: choco install -y pkgconfiglite | ||
|
||
- name: Install libsodium | ||
if: matrix.os == 'windows-latest' | ||
run: | | ||
curl -Ls \ | ||
--connect-timeout 5 \ | ||
--max-time 10 \ | ||
--retry 5 \ | ||
--retry-delay 0 \ | ||
--retry-max-time 40 \ | ||
https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-mingw.tar.gz -o libsodium-1.0.18-mingw.tar.gz | ||
tar zxvf libsodium-1.0.18-mingw.tar.gz | ||
sed -i "s|/d/a/1/s/|D:/a/cardano-node/cardano-node/|g" libsodium-win64/lib/pkgconfig/libsodium.pc | ||
export PKG_CONFIG_PATH="$(readlink -f libsodium-win64/lib/pkgconfig)" | ||
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV | ||
export LIBSODIUM_PATH="$(readlink -f libsodium-win64/bin | sed 's|^/d|D:|g' | tr / '\\')" | ||
echo "LIBSODIUM_PATH=$LIBSODIUM_PATH" | ||
echo "$LIBSODIUM_PATH" >> $GITHUB_PATH | ||
- name: Configure to use libsodium | ||
run: | | ||
cat >> cabal.project <<EOF | ||
package cardano-crypto-praos | ||
flags: -external-libsodium-vrf | ||
EOF | ||
- uses: actions/setup-haskell@v1 | ||
id: setup-haskell | ||
with: | ||
ghc-version: ${{ matrix.ghc }} | ||
cabal-version: '3.4.0.0-rc4' | ||
|
||
- name: Install build environment | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get -y install libsodium23 libsodium-dev | ||
sudo apt-get -y install libsystemd0 libsystemd-dev | ||
sudo apt-get -y remove --purge software-properties-common | ||
sudo apt-get -y autoremove | ||
- name: Set up temp directory | ||
run: | | ||
echo 'TMPDIR=${{ runner.temp }}' >> $GITHUB_ENV | ||
echo 'TMP=${{ runner.temp }}' >> $GITHUB_ENV | ||
- uses: actions/cache@v2 | ||
name: Cache cabal store | ||
with: | ||
path: ${{ steps.setup-haskell.outputs.cabal-store }} | ||
key: cache-haddock-${{ runner.os }}-${{ matrix.ghc }}-v1-${{ hashFiles('cabal-cache.cabal') }}-${{ github.sha }} | ||
restore-keys: | | ||
cache-haddock-${{ runner.os }}-${{ matrix.ghc }}-v1-${{ hashFiles('cabal-cache.cabal') }}- | ||
cache-haddock-${{ runner.os }}-${{ matrix.ghc }}-v1- | ||
- name: Update Hackage index | ||
run: cabal update | ||
|
||
- name: Checkout ouroboros-network repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Build dependencies | ||
run: cabal --builddir="$CABAL_BUILDDIR" configure --enable-tests | ||
|
||
- name: Use cabal.project.local.github-pages | ||
run: | | ||
cat ./cabal.project.local.github-pages >> ./cabal.project.local | ||
cat ./cabal.project.local | ||
- name: build Haddock documentation 🔧 | ||
run: | | ||
mkdir ./haddocks | ||
./scripts/haddocs.sh ./haddocks | ||
- name: deploy to gh-pages 🚀 | ||
run: | | ||
git fetch origin gh-pages:gh-pages | ||
git checkout gh-pages | ||
cp -r ./haddocks/* ./ | ||
rm -rf haddocks | ||
git add -A | ||
git commit -m "Deployed haddocks" || true | ||
git push https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git HEAD:gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/bin/bash | ||
# Build haddock documentation and an index for all projects in | ||
# `ouroboros-network` repository. | ||
# | ||
# usage: | ||
# ./haddocks.sh directory [true|false] | ||
# | ||
# $1 - where to put the generated pages, this directory contents will be wiped | ||
# out (so don't pass `/` or `./` - the latter will delete your 'dist-newstyle') | ||
# (the default is './haddocks') | ||
# $2 - weahter to re-build haddocjs with `cabal haddock` command or a component name | ||
# (the default is true) | ||
# $3 - cabal build directory | ||
# (the default is "dist-newstyle") | ||
|
||
set -euo pipefail | ||
|
||
OUTPUT_DIR=${1:-"./haddocks"} | ||
REGENERATE=${2:-"true"} | ||
BUILD_DIR=${3:-"dist-newstyle"} | ||
|
||
GHC_VERSION=$(ghc --numeric-version) | ||
OS_ARCH="$(cat "$BUILD_DIR/cache/plan.json" | jq -r '.arch + "-" + .os' | head -n 1 | xargs)" | ||
|
||
|
||
# we don't include `--use-index` option, because then quickjump data is not | ||
# generated. This is not ideal, but there is no way to generate only top level | ||
# `doc-index.html` file. With this approach we get: | ||
# * `doc-index.json` and `doc-index.html` per package | ||
# * we can generate top level `doc-index.json` (which will only work at the top | ||
# level). | ||
# * we could ammend package level `doc-index.json` files, but it's enough ... | ||
# this should be fixed upstream. | ||
HADDOCK_OPTS=( | ||
--builddir "${BUILD_DIR}" | ||
--disable-optimization | ||
--haddock-all | ||
--haddock-internal | ||
--haddock-html | ||
--haddock-quickjump | ||
--haddock-hyperlink-source | ||
--haddock-option "--show-all" | ||
--haddock-option "--use-unicode" | ||
--haddock-option "--use-contents=\"../index.html\"" | ||
) | ||
|
||
# build documentation of all modules | ||
if [ ${REGENERATE} == "true" ]; then | ||
cabal haddock "${HADDOCK_OPTS[@]}" cardano-api | ||
elif [ ${REGENERATE} != "false" ]; then | ||
cabal haddock "${HADDOCK_OPTS[@]}" ${REGENERATE} | ||
fi | ||
|
||
if [[ !( -d ${OUTPUT_DIR} ) ]]; then | ||
mkdir -p ${OUTPUT_DIR} | ||
fi | ||
|
||
# copy the new docs | ||
for noopt_dir in $(ls "${BUILD_DIR}/build/${OS_ARCH}/ghc-${GHC_VERSION}"/noopt); do | ||
dir="$(dirname "$noopt_dir")" | ||
package=$(echo "${dir}" | sed 's/-[0-9]\+\(\.[0-9]\+\)*//') | ||
cp -r "${BUILD_DIR}/build/${OS_ARCH}/ghc-${GHC_VERSION}/${dir}/noopt/doc/html/${package}" ${OUTPUT_DIR} | ||
done | ||
|
||
# --read-interface options | ||
interface_options () { | ||
for package in $(ls "${OUTPUT_DIR}"); do | ||
echo "--read-interface=${package},${OUTPUT_DIR}/${package}/${package}.haddock" | ||
done | ||
} | ||
|
||
# Generate top level index using interface files | ||
# | ||
haddock \ | ||
-o ${OUTPUT_DIR} \ | ||
--title "ouroboros-network" \ | ||
--package-name "Ouroboros-Network & Ouroboros-Consensus" \ | ||
--gen-index \ | ||
--gen-contents \ | ||
--quickjump \ | ||
--prolog ./scripts/prolog \ | ||
$(interface_options) | ||
|
||
# Assemble a toplevel `doc-index.json` from package level ones. | ||
# | ||
echo "[]" > "${OUTPUT_DIR}/doc-index.json" | ||
for file in $(ls $OUTPUT_DIR/*/doc-index.json); do | ||
project=$(basename $(dirname $file)); | ||
jq -s \ | ||
".[0] + [.[1][] | (. + {link: (\"${project}/\" + .link)}) ]" \ | ||
"${OUTPUT_DIR}/doc-index.json" \ | ||
${file} \ | ||
> /tmp/doc-index.json | ||
mv /tmp/doc-index.json "${OUTPUT_DIR}/doc-index.json" | ||
done |
Oops, something went wrong.