dda-python-terraform/.gitlab-ci.yml

118 lines
2.7 KiB
YAML
Raw Permalink Normal View History

2022-08-05 15:53:29 +00:00
image: "python:3.8"
before_script:
- python --version
- pip install setuptools wheel twine
- pip install .
- pip install -r requirements_dev.txt
stages:
- lint
- test
- build
- upload
flake8:
stage: lint
allow_failure: true
script:
- flake8 --max-line-length=120 --count --select=E9,F63,F7,F82 --show-source --statistics python_terraform/*.py
- flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics python_terraform/*.py
mypy:
stage: lint
allow_failure: true
script:
- python -m mypy python_terraform/terraform.py
- python -m mypy python_terraform/tfstate.py
pylint:
stage: lint
allow_failure: true
script:
- pylint -d C0301 python_terraform/*.py
test-0.13.7:
stage: test
script:
- export TFVER=0.13.7
- export TFURL=https://releases.hashicorp.com/terraform/
- TFURL+=$TFVER
- TFURL+="/terraform_"
- TFURL+=$TFVER
- TFURL+="_linux_amd64.zip"
- wget $TFURL -O terraform_bin.zip
- mkdir tf_bin
- unzip terraform_bin.zip -d tf_bin
- PATH=$PATH:$PWD/tf_bin
- pytest -v
test-1.0.8:
stage: test
script:
- export TFVER=1.0.8
- export TFURL=https://releases.hashicorp.com/terraform/
- TFURL+=$TFVER
- TFURL+="/terraform_"
- TFURL+=$TFVER
- TFURL+="_linux_amd64.zip"
- wget $TFURL -O terraform_bin.zip
- mkdir tf_bin
- unzip terraform_bin.zip -d tf_bin
- PATH=$PATH:$PWD/tf_bin
- pytest -v
test-1.1.3:
stage: test
script:
- export TFVER=1.1.3
- export TFURL=https://releases.hashicorp.com/terraform/
- TFURL+=$TFVER
- TFURL+="/terraform_"
- TFURL+=$TFVER
- TFURL+="_linux_amd64.zip"
- wget $TFURL -O terraform_bin.zip
- mkdir tf_bin
- unzip terraform_bin.zip -d tf_bin
- PATH=$PATH:$PWD/tf_bin
- pytest -v
build:
stage: build
rules:
- if: '$CI_COMMIT_TAG =~ /^release-.*$/'
artifacts:
paths:
- dist/*
script:
- python setup.py sdist bdist_wheel
pypi:
stage: upload
rules:
- if: '$CI_COMMIT_TAG =~ /^release-.*$/'
script:
- twine upload dist/*
gitlab:
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: upload
rules:
- if: '$CI_COMMIT_TAG =~ /^release-.*$/'
artifacts:
paths:
- release/*
before_script:
- echo "upload to gitlab"
script:
- apk --no-cache add curl
- cp -r dist release
- cd release
- rm *.whl
- find . -type f -exec sha256sum {} \; | sort > sha256sum.lst
- find . -type f -exec sha512sum {} \; | sort > sha512sum.lst
- |
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
--assets-link "{\"name\":\"release\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/python-terraform/-/jobs/${CI_JOB_ID}/artifacts/file/release\"}" \