mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-24 22:06:43 +01:00
94 lines
3.9 KiB
YAML
94 lines
3.9 KiB
YAML
# This configuration was automatically generated from a CircleCI 1.0 config.
|
|
version: 2
|
|
jobs:
|
|
build:
|
|
machine: true
|
|
# we hard code this because even in a fork our code references the canonical import urls
|
|
working_directory: ~/.go_workspace/src/github.com/ansible-semaphore/semaphore
|
|
steps:
|
|
# Remove go and restore the dependency cache
|
|
- run: sudo rm -rf /usr/local/go
|
|
- run: mkdir -p ${GOPATH}/bin
|
|
- restore_cache:
|
|
keys:
|
|
# This branch if available
|
|
- v4-dep-{{ .Branch }}-
|
|
# Default branch if not
|
|
- v4-dep-develop-
|
|
# Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
|
|
- v4-dep-
|
|
- run: sudo apt-get update
|
|
- run: sudo apt-get install rpm
|
|
# Install node and go
|
|
- run:
|
|
name: Install node
|
|
command: |
|
|
set +e
|
|
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
|
|
export NVM_DIR="/opt/circleci/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
nvm install 8.2.0 && nvm alias default 8.2.0
|
|
# Each step uses the same `$BASH_ENV`, so need to modify it
|
|
echo 'export NVM_DIR="/opt/circleci/.nvm"' >> $BASH_ENV
|
|
echo "[ -s \"$NVM_DIR/nvm.sh\" ] && . \"$NVM_DIR/nvm.sh\"" >> $BASH_ENV
|
|
- run: sudo curl -L https://storage.googleapis.com/golang/go1.10.linux-amd64.tar.gz > /tmp/go.tar.gz
|
|
- run: sudo tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
# Needed for task orchestration
|
|
- run: go get -u -v github.com/go-task/task/cmd/task
|
|
# Needed only in ci to post coverage reports
|
|
- run: go get github.com/schrej/godacov
|
|
# Get app and install all its deps
|
|
- checkout
|
|
# Circle can provide a concatenated gopath and the second item is not actually in the path
|
|
# which will cause builds to fail if deps are placed there
|
|
- run: GOPATH=/home/circleci/.go_workspace task deps
|
|
- run: task deps:docker
|
|
# Save dependency cache
|
|
- save_cache:
|
|
key: v4-dep-{{ .Branch }}-{{ epoch }}
|
|
paths:
|
|
- ~/.go_workspace/src/github.com/ansible-semaphore/semaphore
|
|
- ~/.go_workspace/bin
|
|
- /opt/circleci/.nvm
|
|
# Post cache compile
|
|
- run: task compile
|
|
# Test
|
|
# This looks like utter filth in circleci v2 but we have no choice apart from this escaping madness
|
|
- run: "cat > config.json <<EOF\n{\n\t\"mysql\": {\n\t\t\"host\": \"0.0.0.0:3306\"\
|
|
,\n\t\t\"user\": \"root\",\n\t\t\"pass\": \"\",\n\t\t\"name\": \"circle_test\"\
|
|
\n\t},\n\t\"email_alert\": false\n}\nEOF\n"
|
|
- run: |
|
|
docker run -d -p "3306:3306" --health-cmd='mysqladmin ping --silent' -e MYSQL_ALLOW_EMPTY_PASSWORD=true -e MYSQL_DATABASE=circle_test --name=mysql mysql:5.6
|
|
function getContainerHealth {
|
|
docker inspect --format "{{json .State.Health.Status }}" $1
|
|
}
|
|
|
|
function waitContainer {
|
|
while STATUS=$(getContainerHealth $1); [ $STATUS != "\"healthy\"" ]; do
|
|
if [ $STATUS == "\"unhealthy\"" ]; then
|
|
exit -1
|
|
fi
|
|
printf .
|
|
sleep 1
|
|
done
|
|
}
|
|
|
|
waitContainer mysql
|
|
- run: go run cli/main.go --migrate -config config.json
|
|
- run: docker stop mysql && docker rm mysql
|
|
- run: task test
|
|
- run: context=prod task docker:test
|
|
# Build artifacts for all architectures
|
|
- run: task build
|
|
# Post coverage
|
|
- run: godacov -t "${CODACY_TOKEN}" -r ./coverage.out -c "${CIRCLE_SHA1}" || true
|
|
# Teardown
|
|
# Save test results
|
|
- store_test_results:
|
|
path: ~/.go_workspace/src/github.com/ansible-semaphore/semaphore/coverage.out
|
|
# Save artifacts
|
|
- store_artifacts:
|
|
path: ~/.go_workspace/src/github.com/ansible-semaphore/semaphore/bin
|
|
- store_artifacts:
|
|
path: ~/.go_workspace/src/github.com/ansible-semaphore/semaphore/coverage.out
|