From 3edc4042456296a2b11fa5bed6633d236dc7a352 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Aug 2020 10:20:20 -0500 Subject: [PATCH 1/3] ci(tests): Add poetry caching from libvcs --- .github/workflows/tests.yml | 60 ++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index af22160f4..dbf975a43 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,7 +12,49 @@ jobs: tmux-version: [ '2.6', '2.7', '2.8', '3.0', 'master' ] steps: - uses: actions/checkout@v1 - - name: Cache tmux build ${{ matrix.tmux-version }} + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Get full Python version + id: full-python-version + shell: bash + run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))") + + - name: Install poetry + run: | + curl -O -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py + python get-poetry.py -y + echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH" + rm get-poetry.py + + - name: Get poetry cache paths from config + run: | + echo ::set-env name=poetry_cache_dir::$(poetry config --list | sed -n 's/.*cache-dir = //p' | sed -e 's/^"//' -e 's/"$//') + echo ::set-env name=poetry_virtualenvs_path::$(poetry config --list | sed -n 's/.*virtualenvs.path = .* # //p' | sed -e 's/^"//' -e 's/"$//') + + - name: Configure poetry + shell: bash + run: poetry config virtualenvs.in-project true + + - name: Set up poetry cache + uses: actions/cache@v2 + id: cache + with: + path: | + .venv + {{ env.poetry_cache_dir }} + {{ env.poetry_virtualenvs_path }} + key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }} + + - name: Ensure cache is healthy + if: steps.cache.outputs.cache-hit == 'true' + shell: bash + run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv + + - name: Setup tmux build cache for tmux ${{ matrix.tmux-version }} id: tmux-build-cache uses: actions/cache@v1 with: @@ -33,18 +75,14 @@ jobs: export PATH=$HOME/tmux-builds/tmux-${{ matrix.tmux-version }}/bin:$PATH cd ~ tmux -V - - name: Configure git - run: | - git config --global user.name 'travis-ci' - git config --global user.email 'travis@nowhere.edu' - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 - with: - python-version: ${{ matrix.python-version }} + + - name: Upgrade pip + shell: bash + run: poetry run python -m pip install pip -U + - name: Install python dependencies run: | - python -m pip install --upgrade poetry - poetry install + poetry install -E "test coverage lint" - name: Lint with flake8 run: | poetry run flake8 From ad32fca2c1625c9c7ead133d959c546c1b8d4dae Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Aug 2020 10:27:15 -0500 Subject: [PATCH 2/3] ci: See if this only runs one time in PRs If we keep this, credit goes to @DanTup See also: - https://github.community/t/duplicate-checks-on-push-and-pull-request-simultaneous-event/18012/6 - https://github.com/Dart-Code/Dart-Code/commit/612732d5879730608baa9622bf7f5e5b7b51ae65 --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dbf975a43..71ea83bda 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -4,6 +4,8 @@ on: [push, pull_request] jobs: build: + # Don't run twice for internal PRs from our own repo + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository runs-on: ubuntu-latest strategy: From 79a1bf1b7bb1892445076d37ebec0fc230d34347 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sun, 16 Aug 2020 10:31:10 -0500 Subject: [PATCH 3/3] ci: Add python 2.7 --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 71ea83bda..b077c871e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.x' ] + python-version: [ '2.7', '3.x' ] tmux-version: [ '2.6', '2.7', '2.8', '3.0', 'master' ] steps: - uses: actions/checkout@v1