From e92b957e3a7324d79f2ef2a7386ed21549a5cb10 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 19 Nov 2019 18:15:08 +0100 Subject: Use Github Actions for CI (#3713) switch to github actions for CI --- .github/workflows/main.yml | 210 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 .github/workflows/main.yml (limited to '.github') diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..c9f83e4e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,210 @@ +name: CI + +on: [push, pull_request] + +# We currently use Python 3.7 for most things: +# - zstandard currently doesn't have 3.8 wheels, +# - we need to upgrade cryptography from version 2.4, which also doesn't have wheels + +env: + # Codecov + CODECOV_TOKEN: "0409bdfd-57a4-477d-a8af-f6172ef431d3" + +jobs: + lint-pr: + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: TrueBrain/actions-flake8@v1.2 + lint-local: + # do not use external action when secrets are exposed. + if: github.event_name == 'push' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + - run: pip install flake8 + - run: flake8 mitmproxy pathod examples test release + mypy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + - run: pip install mypy + - run: mypy . + test: + strategy: + fail-fast: false + matrix: + os: [macos-latest, windows-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - run: printenv + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + - run: pip install tox + - run: tox -e py37 + # codecov's GitHub action only supports Linux. https://github.com/codecov/codecov-action/issues/7 + # codecov's Python uploader has no github actions support yet. https://github.com/codecov/codecov-python/pull/214 + - name: Extract branch name # https://stackoverflow.com/a/58035262/934719 + shell: bash + run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" + id: extract_branch + - run: pip install codecov + - run: > + codecov -f coverage.xml + --name python-${{ matrix.os }} + --commit ${{ github.sha }} + --slug ${{ github.repository }} + --branch ${{ steps.extract_branch.outputs.branch }} + test-py35: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.5' + - run: pip install tox + - run: tox -e py35 + build-wheel: + runs-on: ubuntu-latest + env: + CI_BUILD_WHEEL: 1 + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + - run: pip install tox + - run: tox -e cibuild -- build + - uses: actions/upload-artifact@master + with: + name: wheel + path: release/dist + build-binaries: + strategy: + fail-fast: false + matrix: + # Old Ubuntu version for old glibc + os: [macos-latest, windows-latest, ubuntu-16.04] + runs-on: ${{ matrix.os }} + env: + CI_BUILD_PYINSTALLER: 1 + CI_BUILD_WININSTALLER: ${{ matrix.os == 'windows-latest' }} + CI_BUILD_KEY: ${{ secrets.CI_BUILD_KEY }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + - if: matrix.os == 'windows-latest' + uses: actions/cache@v1 + with: + path: release/installbuilder/setup + key: installbuilder + - run: pip install tox + - run: tox -e cibuild -- build + # artifacts must have different names, see https://github.com/actions/upload-artifact/issues/24 + - uses: actions/upload-artifact@master + with: + name: binaries.${{ matrix.os }} + path: release/dist + + test-web-ui: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - run: git rev-parse --abbrev-ref HEAD + - uses: actions/setup-node@v1 + - id: yarn-cache + run: echo "::set-output name=dir::$(yarn cache dir)" + - uses: actions/cache@v1 + with: + path: ${{ steps.yarn-cache.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - working-directory: ./web + run: yarn + - working-directory: ./web + run: npm test + - run: bash <(curl -s https://codecov.io/bash) + + docs: + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + - run: pip install tox + - run: | + wget https://github.com/gohugoio/hugo/releases/download/v0.59.1/hugo_0.59.1_Linux-64bit.deb + sudo dpkg -i hugo*.deb + - run: tox -e docs + + # Separate from everything else because slow. + build-and-deploy-docker: + if: github.repository == 'mitmproxy/mitmproxy' && github.event_name == 'push' + needs: [test, test-web-ui, build-wheel] + runs-on: ubuntu-latest + env: + CI_BUILD_DOCKER: 1 + DOCKER_USERNAME: mitmbot + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + - run: pip install tox + - uses: actions/download-artifact@master + with: + name: wheel + path: release/dist + - run: tox -e cibuild -- build + - run: tox -e cibuild -- upload + + deploy: + if: github.repository == 'mitmproxy/mitmproxy' && github.event_name == 'push' + runs-on: ubuntu-latest + needs: [test, test-web-ui, build-wheel, build-binaries] + env: + CI_BUILD_WHEEL: 1 + CI_BUILD_PYINSTALLER: 1 + CI_BUILD_WININSTALLER: 1 + TWINE_USERNAME: mitmproxy + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + steps: + - uses: actions/checkout@v1 + - uses: actions/setup-python@v1 + with: + python-version: '3.7' + # artifacts must be downloaded individually, see https://github.com/actions/download-artifact/issues/6 + - uses: actions/download-artifact@master + with: + name: wheel + path: release/dist + - uses: actions/download-artifact@master + with: + name: binaries.windows-latest + path: release/dist + - uses: actions/download-artifact@master + with: + name: binaries.macos-latest + path: release/dist + - uses: actions/download-artifact@master + with: + name: binaries.ubuntu-16.04 + path: release/dist + - run: ls release/dist + - run: pip install tox + - run: tox -e cibuild -- upload -- cgit v1.2.3