Merge pull request #476 from libp2p/github-actions

ci: migrate from CircleCI to GitHub Actions
This commit is contained in:
Piotr Galar
2024-08-05 19:20:44 +02:00
committed by GitHub
3 changed files with 43 additions and 327 deletions

View File

@ -1,315 +0,0 @@
version: 2.1
# heavily inspired by https://raw.githubusercontent.com/pinax/pinax-wiki/6bd2a99ab6f702e300d708532a6d1d9aa638b9f8/.circleci/config.yml
common: &common
working_directory: ~/repo
steps:
- checkout
- run:
name: merge pull request base
command: ./.circleci/merge_pr.sh
- run:
name: merge pull request base (2nd try)
command: ./.circleci/merge_pr.sh
when: on_fail
- run:
name: merge pull request base (3rd try)
command: ./.circleci/merge_pr.sh
when: on_fail
- restore_cache:
keys:
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
- run:
name: install dependencies
command: |
python -m pip install --upgrade pip
python -m pip install tox
- run:
name: run tox
command: python -m tox run -r
- save_cache:
paths:
- .hypothesis
- .tox
- ~/.cache/pip
- ~/.local
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
orbs:
win: circleci/windows@5.0.0
windows-wheel-steps:
windows-wheel-setup: &windows-wheel-setup
executor:
name: win/default
shell: bash.exe
working_directory: C:\Users\circleci\project\py-libp2p
environment:
TOXENV: windows-wheel
restore-cache-step: &restore-cache-step
restore_cache:
keys:
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
install-pyenv-step: &install-pyenv-step
run:
name: install pyenv
command: |
pip install pyenv-win --target $HOME/.pyenv
echo 'export PYENV="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
echo 'export PYENV_ROOT="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
echo 'export PYENV_USERPROFILE="$HOME/.pyenv/pyenv-win/"' >> $BASH_ENV
echo 'export PATH="$PATH:$HOME/.pyenv/pyenv-win/bin"' >> $BASH_ENV
echo 'export PATH="$PATH:$HOME/.pyenv/pyenv-win/shims"' >> $BASH_ENV
source $BASH_ENV
pyenv update
install-latest-python-step: &install-latest-python-step
run:
name: install latest python version and tox
command: |
LATEST_VERSION=$(pyenv install --list | grep -E "${MINOR_VERSION}\.[0-9]+$" | tail -1)
echo "installing python version $LATEST_VERSION"
pyenv install $LATEST_VERSION
pyenv global $LATEST_VERSION
python3 -m pip install --upgrade pip
python3 -m pip install tox
run-tox-step: &run-tox-step
run:
name: run tox
command: |
echo 'running tox with' $(python3 --version)
python3 -m tox run -r
save-cache-step: &save-cache-step
save_cache:
paths:
- .tox
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
docs: &docs
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
- run:
name: install dependencies
command: |
python -m pip install --upgrade pip
python -m pip install tox
- run:
name: install latexpdf dependencies
command: |
sudo apt-get update
sudo apt-get install latexmk tex-gyre texlive-fonts-extra
- run:
name: run tox
command: python -m tox run -r
- save_cache:
paths:
- .tox
- ~/.cache/pip
- ~/.local
key: cache-v1-{{ arch }}-{{ .Environment.CIRCLE_JOB }}-{{ checksum "setup.py" }}-{{ checksum "tox.ini" }}
resource_class: xlarge
interop: &interop
docker:
- image: common
steps:
- run:
name: install interop test dependencies
command: |
sudo apt-get update
wget https://dl.google.com/go/$GOBINPKG
sudo tar -C /usr/local -xzf $GOBINPKG
export GOPATH=$HOME/go
export GOROOT=/usr/local/go
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
./tests_interop/go_pkgs/install_interop_go_pkgs.sh
jobs:
docs:
<<: *docs
docker:
- image: cimg/python:3.9
environment:
TOXENV: docs
py38-core:
<<: *common
docker:
- image: cimg/python:3.8
environment:
TOXENV: py38-core
py39-core:
<<: *common
docker:
- image: cimg/python:3.9
environment:
TOXENV: py39-core
py310-core:
<<: *common
docker:
- image: cimg/python:3.10
environment:
TOXENV: py310-core
py311-core:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-core
py312-core:
<<: *common
docker:
- image: cimg/python:3.12
environment:
TOXENV: py312-core
py38-lint:
<<: *common
docker:
- image: cimg/python:3.8
environment:
TOXENV: py38-lint
py39-lint:
<<: *common
docker:
- image: cimg/python:3.9
environment:
TOXENV: py39-lint
py310-lint:
<<: *common
docker:
- image: cimg/python:3.10
environment:
TOXENV: py310-lint
py311-lint:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-lint
py312-lint:
<<: *common
docker:
- image: cimg/python:3.12
environment:
TOXENV: py312-lint
py38-wheel:
<<: *common
docker:
- image: cimg/python:3.8
environment:
TOXENV: py38-wheel
py39-wheel:
<<: *common
docker:
- image: cimg/python:3.9
environment:
TOXENV: py39-wheel
py310-wheel:
<<: *common
docker:
- image: cimg/python:3.10
environment:
TOXENV: py310-wheel
py311-wheel:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-wheel
py312-wheel:
<<: *common
docker:
- image: cimg/python:3.12
environment:
TOXENV: py312-wheel
py311-windows-wheel:
<<: *windows-wheel-setup
steps:
- checkout
- <<: *restore-cache-step
- <<: *install-pyenv-step
- run:
name: set minor version
command: echo "export MINOR_VERSION='3.11'" >> $BASH_ENV
- <<: *install-latest-python-step
- <<: *run-tox-step
- <<: *save-cache-step
py312-windows-wheel:
<<: *windows-wheel-setup
steps:
- checkout
- <<: *restore-cache-step
- <<: *install-pyenv-step
- run:
name: set minor version
command: echo "export MINOR_VERSION='3.12'" >> $BASH_ENV
- <<: *install-latest-python-step
- <<: *run-tox-step
- <<: *save-cache-step
py38-interop:
<<: *interop
docker:
- image: cimg/python:3.8
environment:
TOXENV: py38-interop
py39-interop:
<<: *interop
docker:
- image: cimg/python:3.9
environment:
TOXENV: py39-interop
py310-interop:
<<: *interop
docker:
- image: cimg/python:3.10
environment:
TOXENV: py310-interop
py311-interop:
<<: *interop
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-interop
py312-interop:
<<: *interop
docker:
- image: cimg/python:3.12
environment:
TOXENV: py312-interop
workflows:
version: 2
test:
jobs:
- docs
- py38-core
- py39-core
- py310-core
- py311-core
- py312-core
- py38-lint
- py39-lint
- py310-lint
- py311-lint
- py312-lint
- py38-wheel
- py39-wheel
- py310-wheel
- py311-wheel
- py312-wheel
# - py311-windows-wheel
# - py312-windows-wheel
# - py38-interop
# - py39-interop
# - py310-interop
# - py311-interop
# - py312-interop

View File

@ -1,12 +0,0 @@
#!/usr/bin/env bash
if [[ -n "${CIRCLE_PR_NUMBER}" ]]; then
PR_INFO_URL=https://api.github.com/repos/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER
PR_BASE_BRANCH=$(curl -L "$PR_INFO_URL" | python -c 'import json, sys; obj = json.load(sys.stdin); sys.stdout.write(obj["base"]["ref"])')
git fetch origin +"$PR_BASE_BRANCH":circleci/pr-base
# We need these config values or git complains when creating the
# merge commit
git config --global user.name "Circle CI"
git config --global user.email "circleci@example.com"
git merge --no-edit circleci/pr-base
fi

43
.github/workflows/tox.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Run tox
on:
pull_request:
push:
branches:
- master
- github-actions
defaults:
run:
shell: bash
jobs:
tox:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.8', '3.9', '3.10', '3.11', '3.12']
toxenv: [core, lint, wheel]
include:
- python: '3.9'
toxenv: docs
fail-fast: false
steps:
- env:
python: ${{ matrix.python }}
toxenv: ${{ matrix.toxenv }}
run: |
if [[ "$toxenv" == 'docs' ]]; then
echo 'TOXENV=docs' | tee -a $GITHUB_ENV
else
echo "TOXENV=${python}-${toxenv}" | tr -d '.' | tee -a $GITHUB_ENV
fi
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- run: |
python -m pip install --upgrade pip
python -m pip install tox
- run: |
python -m tox run -r