generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (130 loc) · 4.45 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
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 \
--color=yes \
--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/[email protected]
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
- name: Create Release
id: action
uses: LizardByte/[email protected]
with:
allowUpdates: false
artifacts: ''
body: ${{ steps.setup-release.outputs.release_body }}
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 }}