From e641024ebadbe0701f5119f4776c923c8acbaa6d Mon Sep 17 00:00:00 2001 From: Jonathan Zernik Date: Sun, 27 Feb 2022 00:40:14 -0800 Subject: [PATCH] Format github action (#1968) * Format github action * Split github action into separate workflows --- .github/workflows/ci.yml | 40 ++++++++++++++ .github/workflows/docker.yml | 64 +++++++++++++++++++++ .github/workflows/main.yml | 104 ----------------------------------- .github/workflows/pypi.yml | 32 +++++++++++ 4 files changed, 136 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b17cc984 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + schedule: + - cron: '0 10 * * *' # everyday at 10am + push: + branches: + - '**' + tags: + - 'v*.*.*' + pull_request: + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Protoc + uses: arduino/setup-protoc@v1 + + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + pip install -r requirements-dev.txt + + - name: Run tests and collect coverage + run: | + make test + coverage xml + + - name: Coverage + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 00000000..fd47bcf2 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,64 @@ +name: CI + +permissions: + packages: write + +on: + push: + branches: + - '**' + tags: + - 'v*.*.*' + pull_request: + +jobs: + main: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v3 + with: + images: ghcr.io/${{ github.repository_owner }}/squeaknode + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern=v{{version}} + type=semver,pattern=v{{major}}.{{minor}} + type=semver,pattern=v{{major}} + type=sha + + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + platforms: linux/arm64,linux/amd64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,mode=max,dest=/tmp/.buildx-cache diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 24238d9e..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,104 +0,0 @@ -name: CI - -permissions: - packages: write - -on: - schedule: - - cron: '0 10 * * *' # everyday at 10am - push: - branches: - - '**' - tags: - - 'v*.*.*' - pull_request: - -jobs: - main: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - name: Install Protoc - uses: arduino/setup-protoc@v1 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install dependencies - run: | - pip install -r requirements-dev.txt - - name: Run tests and collect coverage - run: | - make test - coverage xml - - - name: Coverage - uses: codecov/codecov-action@v2 - with: - token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos - - - name: Docker meta - id: docker_meta - uses: docker/metadata-action@v3 - with: - images: ghcr.io/${{ github.repository_owner }}/squeaknode - tags: | - type=ref,event=branch - type=ref,event=pr - type=semver,pattern=v{{version}} - type=semver,pattern=v{{major}}.{{minor}} - type=semver,pattern=v{{major}} - type=sha - - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Cache Docker layers - uses: actions/cache@v2 - with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- - - - name: Login to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - id: docker_build - uses: docker/build-push-action@v2 - with: - platforms: linux/arm64,linux/amd64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.docker_meta.outputs.tags }} - labels: ${{ steps.docker_meta.outputs.labels }} - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,mode=max,dest=/tmp/.buildx-cache - build-n-publish: - name: Build and publish Python 🐍 distributions 📦 to PyPI - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@master - - name: Set up Python 3.9 - uses: actions/setup-python@v1 - with: - python-version: 3.9 - - name: Install dependencies and build - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - python setup.py sdist bdist_wheel - - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 00000000..f2aebfee --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,32 @@ +name: PyPi + +on: + push: + branches: + - '**' + tags: + - 'v*.*.*' + pull_request: + +jobs: + build-n-publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@master + - name: Set up Python 3.9 + uses: actions/setup-python@v1 + with: + python-version: 3.9 + + - name: Install dependencies and build + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + python setup.py sdist bdist_wheel + + - name: Publish distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }}