From 9e340efd27153e57c4320e55f93ef1dc383d0eb9 Mon Sep 17 00:00:00 2001 From: Mikkel Pedersen Date: Tue, 11 Jun 2024 14:02:25 +0200 Subject: [PATCH] fix(ci): Add CI --- .github/dependabot.yml | 16 +++++++ .github/workflows/ci.yaml | 90 ++++++++++++++++++++++++++++++++++++ .github/workflows/tests.yaml | 26 +++++++++++ 3 files changed, 132 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/tests.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..30e0b97 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,16 @@ +version: 2 +updates: +- package-ecosystem: pip + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: pytest + - dependency-name: setuptools + - dependency-name: twine + - dependency-name: wheel + commit-message: + prefix: fix + prefix-development: chore + include: scope diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..456a909 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,90 @@ +--- +name: CI + +on: [push, pull_request] + +jobs: + + deploy: + name: Deploy to GitHub + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' && github.repository_owner == 'pollination' + steps: + - uses: actions/checkout@v2 + - name: set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: set up node # we need node for for semantic release + uses: actions/setup-node@v2.1.2 + with: + node-version: 14.2.0 + - name: install python dependencies + run: pip install . + - name: install semantic-release + run: + npm install @semantic-release/exec + - name: run semantic release + id: new_release + run: | + nextRelease="`npx semantic-release@^17.0.0 --dryRun | grep -oP 'Published release \K.*? ' || true`" + npx semantic-release@^17.0.0 + echo "::set-output name=tag::$nextRelease" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PYPI_USERNAME: ${{ secrets.POLLINATION_PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.POLLINATION_PYPI_PASSWORD }} + + outputs: + tag: ${{ steps.new_release.outputs.tag }} + + deploy-to-staging: + name: Deploy to Pollination Staging + runs-on: ubuntu-latest + needs: deploy + if: ${{ github.ref == 'refs/heads/master' && github.repository_owner == 'pollination' && contains(needs.deploy.outputs.tag, '.') }} + steps: + - uses: actions/checkout@v2 + - name: set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: install python dependencies + run: pip install . + - name: deploy to staging + run: | + queenbee + pollination dsl push pollination-abnt-nbr-15575-daylight --tag ${{needs.deploy.outputs.tag}} -e https://api.staging.pollination.cloud -src https://api.staging.pollination.cloud/registries --push-dependencies + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + QB_POLLINATION_TOKEN: ${{ secrets.POLLINATION_STAGING_LADYBUGBOT_TOKEN }} + + deploy-to-production: + name: Deploy to Pollination Production + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/production' && github.repository_owner == 'pollination' + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + - name: Get Job Context + id: get-context + run: | + TAG=$(git describe --tags | sed 's/v//') + echo "Releasing tag: ${TAG:?}" + echo "::set-output name=tag::$TAG" + - name: install python dependencies + run: | + pip install . + pip install -r requirements.txt + - name: deploy to production + run: | + queenbee + pollination dsl push pollination-abnt-nbr-15575-daylight --tag ${{steps.get-context.outputs.tag}} -e https://api.pollination.cloud -src https://api.pollination.cloud/registries --push-dependencies + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + QB_POLLINATION_TOKEN: ${{ secrets.POLLINATION_LADYBUGBOT_TOKEN }} diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..4701f04 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,26 @@ +--- +name: CI + +on: [pull_request] + +jobs: + + test: + name: Unit tests + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - name: set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + - name: install python dependencies + run: | + pip install -r dev-requirements.txt + pip install . + - name: run tests + run: python -m pytest tests/