From 9065aea857b69ba4391a27021e228281106b41fa Mon Sep 17 00:00:00 2001 From: Ujjwal Kumar <78945437+ujjwal-ibm@users.noreply.github.com> Date: Tue, 7 Jan 2025 01:33:31 +0530 Subject: [PATCH] feat(release): fixed ci workflow (#72) * feat(release): fixed ci workflow Signed-off-by: Ujjwal Kumar * feat(release): fixed ci workflow Signed-off-by: Ujjwal Kumar * feat(release): fixed ci workflow Signed-off-by: Ujjwal Kumar * feat(release): fixed ci workflow Signed-off-by: Ujjwal Kumar --------- Signed-off-by: Ujjwal Kumar --- .github/workflows/ci.yml | 66 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 51 ------------------------------- tox.ini | 10 ++++-- 3 files changed, 74 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0bd404b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,66 @@ +name: CI + +on: + push: + branches: [master] + tags: ['v*'] + pull_request: + branches: [master] + +jobs: + test: + runs-on: ubuntu-latest + environment: ci + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + + - name: Install pandoc + run: | + sudo apt-get update + sudo apt-get install pandoc + pip install pypandoc + + - name: Install npm + run: | + sudo npm install -g npm@latest || sudo npm install -g npm@9 + + - name: Install dependencies + run: pip install 'tox<4' tox-gh-actions + + - name: Run tests + env: + PYTHON_VERSION: ${{ matrix.python-version }} + run: tox + + - name: Install release dependencies + if: github.ref == 'refs/heads/master' && matrix.python-version == '3.8' + run: | + pip install bump-my-version + sudo npm install -g --save-dev \ + @semantic-release/changelog \ + @semantic-release/exec \ + @semantic-release/git \ + @semantic-release/github + + - name: Semantic Release + if: github.ref == 'refs/heads/master' && matrix.python-version == '3.8' + run: npx semantic-release + + - name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') && matrix.python-version == '3.8' + run: | + pip install build twine + python -m build + python -m twine upload dist/* -u __token__ -p ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b8ec14f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -language: python - -dist: focal - -cache: pip - -notifications: - email: true - -matrix: - include: - - python: 3.8 - - python: 3.9 - - python: 3.10 - - python: 3.11 - -before_install: -- npm install -g npm@latest || npm install -g npm@9 -- sudo apt-get update -- sudo apt-get install pandoc -- pip install pypandoc - -install: -- pip install tox-travis 'tox<4' - -script: tox - -before_deploy: -- pip install bump-my-version -- nvm install --lts -- npm install @semantic-release/changelog -- npm install @semantic-release/exec -- npm install @semantic-release/git -- npm install @semantic-release/github - -deploy: -- provider: script - script: npx semantic-release - skip_cleanup: true - on: - python: '3.8' - branch: master - -- provider: pypi - user: __token__ - password: $PYPI_TOKEN - edge: true - skip_cleanup: true - on: - python: '3.8' - tags: true diff --git a/tox.ini b/tox.ini index a410091..31477ff 100644 --- a/tox.ini +++ b/tox.ini @@ -1,13 +1,19 @@ [tox] envlist = py37-lint, py37, py38, py39 +[gh-actions] +python = + 3.7: py37, py37-lint + 3.8: py38 + 3.9: py39 + [testenv:py37-lint] basepython = python3.7 deps = pylint commands = pylint --rcfile=.pylintrc ibm-vpc test/unit [testenv] -passenv = TOXENV CI TRAVIS* +passenv = TOXENV CI GITHUB_* commands = pytest -v test/unit @@ -15,4 +21,4 @@ deps = -r{toxinidir}/requirements.txt -r{toxinidir}/requirements-dev.txt usedevelop = True -exclude = .venv,.git,.tox,docs +exclude = .venv,.git,.tox,docs \ No newline at end of file