My .cirrus.yml file looks like:
linux_task:
container:
image: alpine:latest
env:
- GOPATH: ${HOME}/go
- PATH: ${GOPATH}/bin:${PATH}
- GOPROXY: https://proxy.golang.org
setup_script:
- apk add go
- go version
- mkdir ${GOPATH}/src/${CIRRUS_REPO_OWNER}
- cd ${GOPATH}/src/${CIRRUS_REPO_OWNER}
- git clone ${CIRRUS_REPO_CLONE_URL}
- cd ${CIRRUS_REPO_NAME}
build_script:
- go build -race -v ./...
test_script:
- go test -race -count=100 ./...
- go test -race -v -count=1 ./...
But I get the following error when it attempts to run:
FAILED_PRECONDITION: Field 'null' should be a value or at most list of values!
I thought it might be an issue with white-space but this doesn't seem to be the case.
Hey! Thanks for your question.
Because this is a precondition, it seems to be an issue with your .cirrus.yml. If I remember correctly, I don't think you can use ${ITEM} in env variable declarations yet.
Pretty sure there is an issue mentioning this somewhere.
It's because env is expected to be a mapping and not a list:
env:
GOPATH: ${HOME}/go
PATH: ${GOPATH}/bin:${PATH}
GOPROXY: https://proxy.golang.org
BTW why don't you use golang containers like in an example?
Ah, that looks like the issue. I agree, containers would be much quicker.
@fkorotkov That makes sense, thanks!
I considered using the golang images but I need to run tests on specific operating systems and the golang packages weren't flexible enough for this. Are these commands good enough to clone the right branch?
- git clone https://${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git
- cd ${CIRRUS_REPO_NAME}
- git checkout ${CIRRUS_BRANCH}
I've added such syntax support in the parser but please still use env as a map until the fix is deployed 馃槄
@awnumar please check this example with a custom clone command.
@fkorotkov Thanks for that, I didn't notice it in the docs. However it has an issue every time I try to use it. If I do the following:
env:
GOPROXY: https://proxy.golang.org
MODULEPATH: /tmp/go/src/github.com/${CIRRUS_REPO_FULL_NAME}
install_script:
- apk add go
- apk add git
- mkdir -p /tmp/go/src/github.com/${CIRRUS_REPO_OWNER}
clone_script: |
if [[ -z "$CIRRUS_PR" ]]; then
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git ${MODULEPATH}
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git ${MODULEPATH}
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi
export CIRRUS_WORKING_DIR=${MODULEPATH}
export GOPATH=/tmp/go
export PATH=${GOPATH}/bin:${PATH}
then I get the error:
Cloning into '/tmp/go/src/github.com/awnumar/memguard'...
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
Exit status: 128
I've tried a number of things but I can't seem to get rid of it.
This should work:
container:
image: alpine:latest
test_task:
env:
GOPROXY: https://proxy.golang.org
GOPATH: /tmp/go
PATH: ${GOPATH}/bin:${PATH}
CIRRUS_WORKING_DIR: /tmp/go/src/github.com/${CIRRUS_REPO_FULL_NAME}
install_script:
- apk add go git
clone_script: |
if [[ -z "$CIRRUS_PR" ]]; then
git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git ${CIRRUS_WORKING_DIR}
git reset --hard $CIRRUS_CHANGE_IN_REPO
else
git clone --recursive https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git ${CIRRUS_WORKING_DIR}
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
git reset --hard $CIRRUS_CHANGE_IN_REPO
fi
You're a wizard, thank you.