Skip to content

Commit

Permalink
Re-structured CI-Pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaumgarten committed May 30, 2021
1 parent 1344f74 commit 76bde70
Show file tree
Hide file tree
Showing 8 changed files with 1,539 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ docs/vscode-yolol.md
docs/generated/*
docs/nolol-stdlib.md
examples/nolol/*.yolol
CHANGELOG.md
CHANGELOG.md
yodk*.zip
30 changes: 5 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,16 @@ services:
- xvfb
env:
- NODE_VERSION="16.1" GO111MODULE=on

before_install:
- nvm install $NODE_VERSION
install:
- go mod download
- cd vscode-yolol && npm install && npm install -g vsce && cd ..
- ./ci/ci.sh install ${TRAVIS_BRANCH}
before_script:
- export DISPLAY=:99.0;
script:
- go test ./...
- go build -ldflags "-X github.com/dbaumgarten/yodk/cmd.YodkVersion=${TRAVIS_BRANCH}"
- ./yodk version
- GOOS=windows go build -ldflags "-X github.com/dbaumgarten/yodk/cmd.YodkVersion=${TRAVIS_BRANCH}"
- GOOS=darwin go build -o yodk-darwin -ldflags "-X github.com/dbaumgarten/yodk/cmd.YodkVersion=${TRAVIS_BRANCH}"
- cd vscode-yolol
- npm run vscode:prepublish
- npm test --silent
- cd ..
- ./build-changelog.sh
before_deploy:
- cp CHANGELOG.md vscode-yolol/
- cd vscode-yolol
- npm version --no-git-tag-version $(echo ${TRAVIS_TAG} | tr -d v) --allow-same-version
- vsce package
- cp *.vsix ../vscode-yolol.vsix
- cd ..
- zip yodk-win.zip yodk.exe
- zip yodk-linux.zip yodk
- zip yodk-darwin.zip yodk-darwin
- ./build-docs.sh
- ./ci/ci.sh build ${TRAVIS_BRANCH}
- ./ci/ci.sh test ${TRAVIS_BRANCH}
- ./ci/ci.sh prepublish ${TRAVIS_BRANCH}
deploy:
- provider: releases
api-key: $GH_TOKEN
Expand All @@ -49,7 +29,7 @@ deploy:
on:
tags: true
- provider: script
script: vsce publish --packagePath vscode-yolol.vsix -p ${VSCODE_MARKETPLACE_TOKEN}
script: ./ci/ci.sh publish ${TRAVIS_TAG} ${VSCODE_MARKETPLACE_TOKEN}
skip_cleanup: true
on:
tags: true
Expand Down
File renamed without changes.
21 changes: 6 additions & 15 deletions build-docs.sh → ci/build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ set -e
# This way, duplicatin between repo and documentation is reduced massively and the documentation is automatically kept up-to-date.


if [ -f "./yodk" ]; then
YODK_BINARY="./yodk"
elif [ -f "./yodk.exe" ]; then
YODK_BINARY="./yodk.exe"
else
echo No compiled yodk binary found
exit 1
fi

rm -rf docs/generated || true
mkdir -p docs/generated/code/yolol
mkdir -p docs/generated/code/nolol
Expand All @@ -25,17 +16,17 @@ cp examples/yolol/*.yolol docs/generated/code/yolol
cp examples/nolol/*.nolol docs/generated/code/nolol
cp examples/yolol/fizzbuzz_test.yaml docs/generated/tests

${YODK_BINARY} compile docs/generated/code/nolol/*.nolol
${YODK_BINARY} format docs/generated/code/nolol/*.nolol
${YODK_BINARY} format docs/generated/code/yolol/*.yolol
${YODK_BINARY} optimize docs/generated/code/yolol/unoptimized.yolol
./yodk compile docs/generated/code/nolol/*.nolol
./yodk format docs/generated/code/nolol/*.nolol
./yodk format docs/generated/code/yolol/*.yolol
./yodk optimize docs/generated/code/yolol/unoptimized.yolol

cp vscode-yolol/README.md docs/vscode-yolol.md
cp README.md docs/README.md
sed -i 's/https:\/\/dbaumgarten.github.io\/yodk\/#//g' docs/README.md
echo "help" | ${YODK_BINARY} debug examples/yolol/fizzbuzz.yolol | grep -v EOF > docs/generated/cli/debug-help.txt
echo "help" | ./yodk debug examples/yolol/fizzbuzz.yolol | grep -v EOF > docs/generated/cli/debug-help.txt

cat docs/nolol-stdlib-header.md > docs/nolol-stdlib.md
${YODK_BINARY} docs stdlib/src/*.nolol -n 'std/$1' -r 'stdlib/src/(.*).nolol' >> docs/nolol-stdlib.md
./yodk docs stdlib/src/*.nolol -n 'std/$1' -r 'stdlib/src/(.*).nolol' >> docs/nolol-stdlib.md

chmod -R a+r docs
66 changes: 66 additions & 0 deletions ci/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/bin/bash

PHASE=$1
VERSION=$2
VSCE_TOKEN=$3


go="go"
if ! which go; then
go="go.exe"
fi

if [ "$PHASE" == "" ] || [ "$VERSION" == "" ]; then
echo "Usage: ./ci/ci.sh <phase> <version>"
exit 1
fi

set -ex

if [ "$PHASE" == "clean" ]; then
rm -rf yodk* *.zip *.vsix CHANGELOG.md vscode-yolol/*.vsix vscode-yolol/CHANGELOG.md vscode-yolol/bin/yo* || true
rm -rf docs/generated/* docs/vscode-yolol.md docs/README.md docs/nolol-stdlib.md || true

elif [ "$PHASE" == "install" ]; then
go mod download
cd vscode-yolol
npm install
npm install -g vsce
cd ..

elif [ "$PHASE" == "build" ]; then
GOOS=linux $go build -o yodk -ldflags "-X github.com/dbaumgarten/yodk/cmd.YodkVersion=${VERSION}"
GOOS=windows $go build -o yodk.exe -ldflags "-X github.com/dbaumgarten/yodk/cmd.YodkVersion=${VERSION}"
GOOS=darwin $go build -o yodk-darwin -ldflags "-X github.com/dbaumgarten/yodk/cmd.YodkVersion=${VERSION}"
cd vscode-yolol
npm run vscode:prepublish
cd ..

elif [ "$PHASE" == "test" ]; then
$go test ./...
cd vscode-yolol
npm test --silent
cd ..

elif [ "$PHASE" == "prepublish" ]; then
./ci/build-changelog.sh
cp CHANGELOG.md vscode-yolol/
cd vscode-yolol
VERSION=$(echo ${VERSION} | tr -d v)
if ! npm version --no-git-tag-version ${VERSION} --allow-same-version; then
echo No valid version. Using v0.0.0 instead
export VERSION=0.0.0
npm version --no-git-tag-version ${VERSION} --allow-same-version
fi
vsce package
npm version 0.0.0 --allow-same-version
cp vscode-yolol-${VERSION}.vsix ../vscode-yolol.vsix
cd ..
zip yodk-win.zip yodk.exe
zip yodk-linux.zip yodk
zip yodk-darwin.zip yodk-darwin
./ci/build-docs.sh

elif [ "$PHASE" == "publish" ]; then
vsce publish --packagePath vscode-yolol.vsix -p $VSCE_TOKEN
fi
Loading

0 comments on commit 76bde70

Please sign in to comment.