diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 4faa83b..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,101 +0,0 @@ -version: 2.1 -orbs: - docker: circleci/docker@0.5.13 - -defaults: &defaults - docker: - - image: circleci/python:3.7-stretch - environment: - - DATABASE_URL=sqlite:///db.sqlite - - CELERY_BROKER_URL=redis://redis:6379/0 - - - BOT_TOKEN=100500:abc - - MAILGUN_FROM=Note to self - - - image: redis:alpine - -jobs: - build: - <<: *defaults - steps: - - checkout - - restore_cache: - key: deps-{{ checksum "src/requirements.txt" }} - - - run: - command: | - python3 -m venv venv - . venv/bin/activate - pip install -r src/requirements.txt - - - - save_cache: - key: deps-{{ checksum "src/requirements.txt" }} - paths: - - "venv" - - - run: - name: Run Flake8 - command: | - . venv/bin/activate - flake8 - - - persist_to_workspace: - root: . - paths: - - . - - unittest: - <<: *defaults - steps: - - attach_workspace: - at: . - - - run: - command: | - . venv/bin/activate - py.test -x - - deploy: - <<: *defaults - steps: - - attach_workspace: - at: . - - run: - name: Install deploy tooling - command: | - export D_RELEASE=0.3.0 - wget -O - https://raw.githubusercontent.com/f213/d/master/install.sh|sh - - run: - name: Add host key - command: ./d add-host-key - - - run: - name: Update image - command: | - ./d update-image circle@selfmailbot.co selfmailbot f213/selfmailbot:${CIRCLE_SHA1} - - -workflows: - version: 2 - continuous-delivery: - jobs: - - build - - unittest: - requires: - - build - - docker/publish: - image: f213/selfmailbot - path: src - requires: - - unittest - filters: - branches: - only: master - - - deploy: - requires: - - docker/publish - filters: - branches: - only: master diff --git a/.circleci/known_hosts b/.circleci/known_hosts deleted file mode 100644 index 53f33c3..0000000 --- a/.circleci/known_hosts +++ /dev/null @@ -1,2 +0,0 @@ -|1|SXJBSxVNEkYfqZ/a+mvs/Z3VJFE=|D8gQTvib7/87xLUFmOmDa8aCmdI= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBI15wmRenKmX6RdYoKjiCKAAcx01Ju7wTbw8OFfGwKt2zB6LZR0zuWM4gw3Qsa5sLybeC+oO7B+L7ljBXX44x8o= -|1|a5aH/6Zvv/UIlXCfNz0nUbrQPtA=|mxHNqeRoAG0d0cmNsgmayxyVo7g= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBI15wmRenKmX6RdYoKjiCKAAcx01Ju7wTbw8OFfGwKt2zB6LZR0zuWM4gw3Qsa5sLybeC+oO7B+L7ljBXX44x8o= diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..57155b2 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,116 @@ +name: CI + + +on: + push: + branches: + - master + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install poetry + uses: snok/install-poetry@v1 + with: + version: 1.6.1 + + - name: Install python + id: setup-python + uses: actions/setup-python@v4 + with: + cache: 'poetry' + python-version-file: 'pyproject.toml' + + - name: make sure poetry lockfile is up to date + run: poetry check --lock && echo Lockfile is ok, $(poetry --version) + shell: bash + + - name: install deps + if: steps.setup-python.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + - name: Run the linters + run: make lint + + build-images: + needs: lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install python + id: setup-python + uses: actions/setup-python@v4 + with: + python-version-file: 'pyproject.toml' + + - name: Set up qemu + uses: docker/setup-qemu-action@v2 + + - name: Set up buildx + uses: docker/setup-buildx-action@v2 + + - name: Generate image identifier + id: image + uses: ASzc/change-string-case-action@v5 + with: + string: ${{ github.repository_owner }} + + - name: Log in to the container registry + uses: docker/login-action@v2 + if: ${{ github.ref == 'refs/heads/master' }} + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build bot image + uses: docker/build-push-action@v3 + with: + context: . + target: bot + push: ${{ github.ref == 'refs/heads/master' }} + tags: | + ghcr.io/${{ steps.image.outputs.lowercase }}/selfmailbot-bot:latest + ghcr.io/${{ steps.image.outputs.lowercase }}/selfmailbot-bot:${{ github.sha }} + + build-args: | + PYTHON_VERSION=${{ env.python-version }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build web image + uses: docker/build-push-action@v3 + with: + context: . + target: web + push: ${{ github.ref == 'refs/heads/master' }} + tags: | + ghcr.io/${{ steps.image.outputs.lowercase }}/selfmailbot-web:latest + ghcr.io/${{ steps.image.outputs.lowercase }}/selfmailbot-web:${{ github.sha }} + + build-args: | + PYTHON_VERSION=${{ env.python-version }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build background processing worker image + uses: docker/build-push-action@v3 + with: + context: . + target: web + push: ${{ github.ref == 'refs/heads/master' }} + tags: | + ghcr.io/${{ steps.image.outputs.lowercase }}/selfmailbot-worker:latest + ghcr.io/${{ steps.image.outputs.lowercase }}/selfmailbot-worker:${{ github.sha }} + + build-args: | + PYTHON_VERSION=${{ env.python-version }} + cache-from: type=gha + cache-to: type=gha,mode=max