Skip to content

chore: update global workflows (#93) #228

chore: update global workflows (#93)

chore: update global workflows (#93) #228

Workflow file for this run

---
name: CI
on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
push:
branches: [master]
workflow_dispatch:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
action:
env:
environment: # this is accessible through ${{ env.environment }}
${{ github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository &&
'external' || 'internal' }}
environment: # this isn't accessible
${{ github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository &&
'external' || 'internal' }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Modify Homebrew Formula
# ensure the file is unique
run: |
echo "# Created from ${{ github.repository }}@${{ github.sha }}" >> ./tests/Formula/hello_world.rb
- name: Run Action
id: action
uses: ./
with:
contribute_to_homebrew_core: true
formula_file: ${{ github.workspace }}/tests/Formula/hello_world.rb
git_email: ${{ secrets.GH_BOT_EMAIL }}
git_username: ${{ secrets.GH_BOT_NAME }}
org_homebrew_repo: ${{ github.repository }}
org_homebrew_repo_branch: tests-${{ runner.os }}
publish: ${{ env.environment == 'internal' && 'true' || 'false' }} # true if internal, false if external
token: ${{ secrets.GH_BOT_TOKEN }}
upstream_homebrew_core_repo: LizardByte/homebrew-core # we don't want to create a PR against upstream
pytest:
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # we need to fetch the default branch for one of the tests
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Dependencies
shell: bash
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade -r requirements-action.txt
python -m pip install --upgrade -r requirements-dev.txt
- name: Test with pytest
id: test
shell: bash
run: |
echo "::group::Setup Homebrew PATH"
if [[ "${{ runner.os }}" == "Linux" ]]; then
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#homebrew-note
echo "Adding Homebrew to PATH"
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
echo "::endgroup::"
echo "::group::Run Tests"
python -m pytest \
-rxXs \
--tb=native \
--verbose \
--cov=action \
tests
echo "::endgroup::"
- name: Upload coverage
# any except canceled or skipped
if: >-
always() &&
(steps.test.outcome == 'success' || steps.test.outcome == 'failure') &&
startsWith(github.repository, 'LizardByte/')
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
flags: ${{ runner.os }}
token: ${{ secrets.CODECOV_TOKEN }}
release:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs:
- action
- pytest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Release
id: setup-release
uses: LizardByte/setup-release-action@v2024.801.192524
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
- name: Create Release
id: action
uses: LizardByte/create-release-action@v2024.614.221009
with:
allowUpdates: false
artifacts: ''
body: ${{ steps.setup-release.outputs.release_body }}
discussionCategory: announcements
generateReleaseNotes: ${{ steps.setup-release.outputs.release_generate_release_notes }}
name: ${{ steps.setup-release.outputs.release_tag }}
prerelease: true
tag: ${{ steps.setup-release.outputs.release_tag }}
token: ${{ secrets.GH_BOT_TOKEN }}