Skip to content

feat: Integration tests #328

feat: Integration tests

feat: Integration tests #328

Workflow file for this run

# Copyright 2023 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Release Candidate
on:
pull_request:
types: [opened, synchronize, closed]
# Allow workflow to be triggered manually.
workflow_dispatch:
jobs:
stage_release:
# To publish a release, merge the release PR with the label 'release:publish'.
# To stage a release without publishing it, manually invoke the workflow.
# . or apply the 'release:stage' label to a PR.
if: >
(github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'release:publish')) ||
github.event.workflow_dispatch ||
(!github.event.pull_request.merged && contains(github.event.pull_request.labels.*.name, 'release:stage'))
runs-on: ubuntu-latest
steps:
- name: Checkout source for staging
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install --upgrade pip
python -m pip install -e ".[dev]"
- name: Test with pytest & coverage
run: |
python -m pytest --cov=src --cov-report term --cov-report html --cov-report xml -vv
# Build the Python Wheel and the source distribution.
- name: Package release artifacts
run: |
python -m pip install setuptools wheel
python setup.py bdist_wheel sdist
# Attach the packaged artifacts to the workflow output. These can be manually
# downloaded for later inspection if necessary.
- name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
publish_release:
needs: stage_release
# Check whether the release should be published. We publish only when the trigger PR is
# 1. merged
# 2. to the main branch
# 3. with the label 'release:publish', and
# 4. the title prefix 'chore: Release '.
if: >
github.event.pull_request.merged &&
github.ref == 'refs/heads/main' &&
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
startsWith(github.event.pull_request.title, 'chore: Release ')
runs-on: ubuntu-latest
permissions:
# Used to create a short-lived OIDC token which is given to PyPi to identify this workflow job
# See: https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#adding-permissions-settings
# and https://docs.pypi.org/trusted-publishers/using-a-publisher/
id-token: write
contents: write
steps:
- name: Checkout source for publish
uses: actions/checkout@v4
# Download the artifacts created by the stage_release job.
- name: Download release candidates
uses: actions/download-artifact@v3
with:
name: dist
path: dist
- name: Publish preflight check
id: preflight
run: ./.github/scripts/publish_preflight_check.sh
# We pull this action from a custom fork of a contributor until
# https://github.com/actions/create-release/pull/32 is merged. Also note that v1 of
# this action does not support the "body" parameter.
- name: Create release tag
# Skip creating a release tag for prereleases
if: (!contains(github.event.pull_request.labels.*.name, 'release:prerelease'))
uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.preflight.outputs.version }}
release_name: Firebase Functions Python SDK ${{ steps.preflight.outputs.version }}
body: ${{ steps.preflight.outputs.changelog }}
draft: false
prerelease: false
- name: Publish to Pypi
uses: pypa/gh-action-pypi-publish@release/v1