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

118 lines
2.7 KiB
YAML
Raw Normal View History

2021-10-15 14:48:16 +00:00
image: "python:3.8"
2021-10-15 14:33:09 +00:00
before_script:
- python --version
2022-01-19 17:08:22 +00:00
- pip install setuptools wheel twine
2021-10-15 14:59:52 +00:00
- pip install .
2021-10-15 14:48:16 +00:00
- pip install -r dev_requirements.txt
2021-10-15 14:33:09 +00:00
stages:
2021-10-15 15:07:06 +00:00
- lint
2021-10-15 14:37:59 +00:00
- test
2022-01-20 08:30:51 +00:00
- build
2022-01-19 17:08:22 +00:00
- upload
2021-10-15 14:33:09 +00:00
flake8:
2021-10-15 15:07:06 +00:00
stage: lint
allow_failure: true
2021-10-15 14:33:09 +00:00
script:
2022-01-19 17:08:22 +00:00
- 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
2021-10-15 14:37:59 +00:00
2021-10-15 15:07:06 +00:00
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
2022-01-19 16:23:10 +00:00
test-0.13.7:
2021-10-15 14:37:59 +00:00
stage: test
script:
2022-01-19 16:23:10 +00:00
- export TFVER=0.13.7
2021-10-15 14:48:16 +00:00
- 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
2021-10-15 14:59:52 +00:00
- PATH=$PATH:$PWD/tf_bin
- pytest -v
2021-10-15 15:09:10 +00:00
2022-01-19 16:23:10 +00:00
test-1.0.8:
2021-10-15 15:09:10 +00:00
stage: test
script:
2022-01-19 16:23:10 +00:00
- export TFVER=1.0.8
2021-10-15 15:09:10 +00:00
- 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
2022-01-19 16:23:10 +00:00
test-1.1.3:
2021-10-15 15:09:10 +00:00
stage: test
script:
2022-01-19 16:23:10 +00:00
- export TFVER=1.1.3
2021-10-15 15:09:10 +00:00
- 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
2022-01-19 17:08:22 +00:00
2022-01-20 08:30:51 +00:00
build:
stage: build
2022-01-19 17:08:22 +00:00
rules:
2022-01-20 18:06:33 +00:00
- if: '$CI_COMMIT_TAG != null'
2022-01-20 18:00:04 +00:00
artifacts:
paths:
- dist/*
2022-01-19 17:08:22 +00:00
script:
2022-01-20 17:53:18 +00:00
- python setup.py sdist bdist_wheel
pypi:
stage: upload
rules:
2022-01-20 18:06:33 +00:00
- if: '$CI_COMMIT_TAG != null'
2022-01-20 17:53:18 +00:00
script:
2022-01-21 08:16:27 +00:00
- twine upload dist/*
gitlab:
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: upload
rules:
- if: '$CI_COMMIT_TAG != null'
2022-01-21 08:24:22 +00:00
artifacts:
paths:
2022-01-21 08:31:40 +00:00
- release/*
2022-01-21 08:16:27 +00:00
before_script:
- echo "upload to gitlab"
script:
- apk --no-cache add curl
2022-01-21 08:31:40 +00:00
- cp -r dist release
- cd release
- rm *.whl
- find . -type f -exec sha256sum {} \; | sort > sha256sum.lst
- find . -type f -exec sha512sum {} \; | sort > sha512sum.lst
2022-01-21 08:16:27 +00:00
- |
release-cli create --name "Release $CI_COMMIT_TAG" --tag-name $CI_COMMIT_TAG \
2022-01-21 08:31:40 +00:00
--assets-link "{\"name\":\"release\",\"url\":\"https://gitlab.com/domaindrivenarchitecture/python-terraform/-/jobs/${CI_JOB_ID}/artifacts/file/release\"}" \