From cbeec600c9e52f326597256e4df0b5e560f25798 Mon Sep 17 00:00:00 2001 From: Stefanus Kurniawan Date: Mon, 18 Jul 2022 11:59:58 +1000 Subject: [PATCH 1/2] CONFIG: Migration to Github Actions --- .github/workflows/build.yml | 159 ++++++++++++++++++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..da019600 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,159 @@ +name: Build + +on: + pull_request: + branches: + - "*" + +# Cancel in-progress workflow runs on new PR commits. +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + test-library: + name: Build library + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.7.5 + uses: actions/setup-python@v3 + with: + python-version: "3.7.5" + - name: Install tox + run: | + # Install tox + pip install tox==3.20.1 + - name: Run tests using tox + run: | + # Go inside the surround library + cd surround + + # Remove generated tox directory + rm -rf .tox + + # Run tests through tox + tox + + test-cli: + name: Build cli + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.7.5 + uses: actions/setup-python@v3 + with: + python-version: "3.7.5" + - name: Install tox + run: | + # Install tox + pip install tox==3.20.1 + - name: Run tests using tox + run: | + # Go inside the surround cli + cd surround_cli + + # Remove generated tox directory + rm -rf .tox + + # Run tests through tox + tox + + # Run examples + pip install ../surround + python setup.py install + cd .. + find examples/ -iname "*.py" | xargs pylint + ls examples/ | xargs -n 1 -I '{}' python3 examples/'{}'/main.py + + release-library: + name: Release library + runs-on: ubuntu-20.04 + needs: + - test-library + if: >- + github.event_name != 'pull_request' && + github.ref_type == 'tag' && + startsWith(github.ref_name, 'surround-v') + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.7.5 + uses: actions/setup-python@v3 + with: + python-version: "3.7.5" + - name: Publish + run: | + cd surround + + # Remove generated files from last release + rm -rf dist + + # Install required packages + python -m pip install --user --upgrade setuptools wheel twine + + # Setup Pypi config + echo "[distutils]" >> ~/.pypirc + echo "index-servers =" >> ~/.pypirc + echo "pypi" >> ~/.pypirc + echo "surround" >> ~/.pypirc + echo "" >> ~/.pypirc + echo "[pypi]" >> ~/.pypirc + echo "username=__token__" >> ~/.pypirc + echo "password=${{ secrets.PYPI_API_LIB_TOKEN }}" >> ~/.pypirc + echo "" >> ~/.pypirc + echo "[surround]" >> ~/.pypirc + echo "repository = https://upload.pypi.org/legacy/" >> ~/.pypirc + echo "username=__token__" >> ~/.pypirc + echo "password=${{ secrets.PYPI_API_LIB_TOKEN }}" >> ~/.pypirc + + # Build package + python setup.py sdist bdist_wheel + + # Upload package for distribution + python -m twine upload --repository pypi dist/* + + release-cli: + name: Release library + runs-on: ubuntu-20.04 + needs: + - test-cli + if: >- + github.event_name != 'pull_request' && + github.ref_type == 'tag' && + startsWith(github.ref_name, 'surround-cli-v') + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.7.5 + uses: actions/setup-python@v3 + with: + python-version: "3.7.5" + - name: Publish + run: | + cd surround_cli + + # Remove generated files from last release + rm -rf dist + + # Install required packages + python -m pip install --user --upgrade setuptools wheel twine + + # Setup Pypi config + echo "[distutils]" >> ~/.pypirc + echo "index-servers =" >> ~/.pypirc + echo "pypi" >> ~/.pypirc + echo "surround-cli" > ~/.pypirc + echo "" >> ~/.pypirc + echo "[pypi]" >> ~/.pypirc + echo "username=__token__" >> ~/.pypirc + echo "password=${{ secrets.PYPI_API_CLI_TOKEN }}" >> ~/.pypirc + echo "" >> ~/.pypirc + echo "[surround-cli]" >> ~/.pypirc + echo "repository = https://upload.pypi.org/legacy/" >> ~/.pypirc + echo "username=__token__" >> ~/.pypirc + echo "password=${{ secrets.PYPI_API_CLI_TOKEN }}" >> ~/.pypirc + + # Build package + python setup.py sdist bdist_wheel + + # Upload package for distribution + python -m twine upload --repository pypi dist/* From e30ec7469f57d347c66750ccab63597a7335a38d Mon Sep 17 00:00:00 2001 From: Stefanus Kurniawan Date: Mon, 22 Aug 2022 11:44:37 +1000 Subject: [PATCH 2/2] CONFIG: Remove Codefresh file --- codefresh.yml | 133 -------------------------------------------------- 1 file changed, 133 deletions(-) delete mode 100644 codefresh.yml diff --git a/codefresh.yml b/codefresh.yml deleted file mode 100644 index dd5be89f..00000000 --- a/codefresh.yml +++ /dev/null @@ -1,133 +0,0 @@ -# More examples of Codefresh YAML can be found at -# https://codefresh.io/docs/docs/yaml-examples/examples/ - -version: "1.0" -# Stages can help you organize your steps in stages -stages: - - "clone" - - "test" - - "release" - -steps: - clone: - title: "Cloning repository" - type: "git-clone" - repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}" - # CF_BRANCH value is auto set when pipeline is triggered - # Learn more at codefresh.io/docs/docs/codefresh-yaml/variables/ - revision: "${{CF_BRANCH}}" - git: "github" - stage: "clone" - - test: - stage: "test" - type: parallel - steps: - test_lib: - title: "Test Surround Library" - type: "freestyle" # Run any command - image: "python:3.8.10" # The image in which command will be executed - working_directory: "${{clone}}" - commands: - # Go inside the surround library - - cd surround - - # Remove generated tox directory - - rm -rf .tox - - # Install tox - - pip install tox==3.20.1 - - # Run tests through tox - - tox - - test_cli: - title: "Test Surround CLI" - type: "freestyle" # Run any command - image: "python:3.8.10" # The image in which command will be executed - working_directory: "${{clone}}" - commands: - # Go inside the cli - - cd surround_cli - - # Remove generated tox directory - - rm -rf .tox - - # Install tox - - pip install tox==3.20.1 - - # Run tests through tox - - tox - - # Run examples - - pip install ../surround - - python setup.py install - - cd .. - - find examples/ -iname "*.py" | xargs pylint - - ls examples/ | xargs -n 1 -I '{}' python3 examples/'{}'/main.py - - release: - stage: "release" - type: parallel - steps: - release_lib: - title: "Release surround lib to PYPI" - type: "freestyle" - image: "python:3.7.5" # The image in which command will be executed - working_directory: "${{clone}}" # Running command where code cloned - commands: - - cd surround - - # Remove generated files from last release - - rm -rf dist - - # Install required packages - - python3 -m pip install --user --upgrade setuptools wheel twine - - # Setup Pypi config - - echo "[pypi]" > ~/.pypirc - - echo "repository=https://upload.pypi.org/legacy/" >> ~/.pypirc - - echo "username=${{PYPI_USERNAME}}" >> ~/.pypirc - - echo "password=${{PYPI_PASSWORD}}" >> ~/.pypirc - - # Build package - - python3 setup.py sdist bdist_wheel - - # Upload package for distribution - - python3 -m twine upload --repository pypi dist/* - when: - condition: - all: - isMainRepo: '"${{CF_REPO_OWNER}}" == "a2i2"' - isReleaseBranch: 'match("${{CF_BRANCH}}", "surround-v([0-9]+)\.([0-9]+)\.([0-9]+)?$", false) == true' - - release_cli: - title: "Release surround cli to PYPI" - type: "freestyle" - image: "python:3.7.5" # The image in which command will be executed - working_directory: "${{clone}}" # Running command where code cloned - commands: - - cd surround_cli - - # Remove generated files from last release - - rm -rf dist - - # Install required packages - - python3 -m pip install --user --upgrade setuptools wheel twine - - # Setup Pypi config - - echo "[pypi]" > ~/.pypirc - - echo "repository=https://upload.pypi.org/legacy/" >> ~/.pypirc - - echo "username=${{PYPI_USERNAME}}" >> ~/.pypirc - - echo "password=${{PYPI_PASSWORD}}" >> ~/.pypirc - - # Build package - - python3 setup.py sdist bdist_wheel - - # Upload package for distribution - - python3 -m twine upload --repository pypi dist/* - when: - condition: - all: - isMainRepo: '"${{CF_REPO_OWNER}}" == "a2i2"' - isReleaseBranch: 'match("${{CF_BRANCH}}", "surround-cli-v([0-9]+)\.([0-9]+)\.([0-9]+)?$", false) == true'