Skip to content

Commit a90bf21

Browse files
committed
Unified github workflows
1 parent 02d23ea commit a90bf21

File tree

6 files changed

+275
-274
lines changed

6 files changed

+275
-274
lines changed

‎.github/workflows/baseline.yml‎

Lines changed: 271 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,271 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: 'Git Tag Name'
8+
required: false
9+
branch_name:
10+
description: 'Git Branch Name'
11+
required: true
12+
default: '1.x'
13+
push:
14+
branches: [ 1.x ]
15+
paths-ignore:
16+
- 'CHANGELOG.md'
17+
18+
jobs:
19+
build-archives:
20+
name: "Build Archives"
21+
22+
runs-on: ubuntu-latest
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
dependencies:
28+
- "locked"
29+
php-version:
30+
- "8.2"
31+
32+
steps:
33+
- name: "Checkout"
34+
uses: "actions/checkout@v4"
35+
with:
36+
fetch-depth: 0
37+
38+
- name: "Install PHP"
39+
uses: "shivammathur/setup-php@v2"
40+
with:
41+
coverage: none
42+
tools: composer:v2
43+
php-version: "${{ matrix.php-version }}"
44+
ini-values: memory_limit=-1
45+
46+
- name: "Get Composer Cache Directory"
47+
id: composer-cache
48+
run: |
49+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
50+
51+
- name: "Cache Composer dependencies"
52+
uses: "actions/cache@v4"
53+
with:
54+
path: "${{ steps.composer-cache.outputs.dir }}"
55+
key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
56+
restore-keys: |
57+
php-${{ matrix.php-version }}-locked-composer-
58+
59+
- name: "Install locked dependencies"
60+
run: "composer install --no-interaction --no-progress"
61+
62+
- name: "Build PHAR file"
63+
run: "composer build:phar"
64+
65+
- name: "Validate Flow PHAR"
66+
run: |
67+
./build/flow.phar --version
68+
69+
- name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v3
71+
72+
- name: Set up QEMU
73+
uses: docker/setup-qemu-action@v3
74+
75+
- name: Login to GitHub Container Registry
76+
uses: docker/login-action@v3
77+
with:
78+
registry: ghcr.io
79+
username: ${{ github.actor }}
80+
password: ${{ secrets.GITHUB_TOKEN }}
81+
82+
- name: Build Docker Image
83+
uses: docker/build-push-action@v6
84+
with:
85+
context: .
86+
file: ./Dockerfile
87+
push: true
88+
platforms: linux/amd64,linux/arm64
89+
tags: |
90+
ghcr.io/flow-php/flow:latest
91+
target: flow
92+
cache-from: type=gha
93+
cache-to: type=gha,mode=max
94+
95+
- name: "Prepare artifact name"
96+
if: ${{ github.event_name == 'push' }}
97+
shell: bash
98+
run: |
99+
BUILD_TAG=${GITHUB_SHA:0:7}
100+
echo "BUILD_TAG=$BUILD_TAG" >> $GITHUB_ENV
101+
102+
- uses: actions/upload-artifact@v4
103+
with:
104+
name: flow-${{ env.BUILD_TAG }}.phar
105+
path: build/flow.phar
106+
overwrite: true
107+
108+
benchmark-baseline:
109+
name: "Benchmark Baseline"
110+
111+
runs-on: ubuntu-latest
112+
113+
strategy:
114+
fail-fast: false
115+
matrix:
116+
dependencies:
117+
- "locked"
118+
php-version:
119+
- "8.2"
120+
121+
steps:
122+
- name: "Set Git Ref"
123+
run: |
124+
if [[ "${{ github.event_name }}" == "push" ]]; then
125+
echo "GIT_REF=${{ github.ref }}" >> $GITHUB_ENV
126+
elif [[ "${{ github.event.inputs.tag_name }}" != "" ]]; then
127+
echo "GIT_REF=refs/tags/${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
128+
else
129+
echo "GIT_REF=${{ github.event.inputs.branch_name }}" >> $GITHUB_ENV
130+
fi
131+
132+
- name: "Set Benchmark Tag"
133+
run: |
134+
if [[ "${{ github.event_name }}" == "push" ]]; then
135+
echo "PHPBENCH_TAG=1.x" >> $GITHUB_ENV
136+
elif [[ "${{ github.event.inputs.tag_name }}" != "" ]]; then
137+
echo "PHPBENCH_TAG=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
138+
else
139+
echo "PHPBENCH_TAG=${{ github.event.inputs.branch_name }}" >> $GITHUB_ENV
140+
fi
141+
142+
- name: "Checkout to specific ref"
143+
uses: "actions/checkout@v4"
144+
with:
145+
ref: ${{ env.GIT_REF }}
146+
147+
- name: "Install PHP"
148+
uses: "shivammathur/setup-php@v2"
149+
with:
150+
coverage: none
151+
tools: composer:v2
152+
php-version: "${{ matrix.php-version }}"
153+
ini-values: memory_limit=-1
154+
155+
- name: "Get Composer Cache Directory"
156+
id: composer-cache
157+
run: |
158+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
159+
160+
- name: "Cache Composer dependencies"
161+
uses: "actions/cache@v4"
162+
with:
163+
path: "${{ steps.composer-cache.outputs.dir }}"
164+
key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}"
165+
restore-keys: |
166+
php-${{ matrix.php-version }}-locked-composer-
167+
168+
- name: "Install locked dependencies"
169+
run: "composer install --no-interaction --no-progress"
170+
171+
- name: "Benchmark"
172+
run: |
173+
echo '# Flow PHP - Benchmark - ${{ env.PHPBENCH_TAG }}' >> $GITHUB_STEP_SUMMARY
174+
echo ' ' >> $GITHUB_STEP_SUMMARY
175+
echo '---' >> $GITHUB_STEP_SUMMARY
176+
echo '```' >> $GITHUB_STEP_SUMMARY
177+
tools/phpbench/vendor/bin/phpbench run --report=flow-report --tag=${{ env.PHPBENCH_TAG }} --progress=none >> $GITHUB_STEP_SUMMARY
178+
echo '```' >> $GITHUB_STEP_SUMMARY
179+
180+
- name: "Store Benchmark baseline"
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: phpbench-baseline
184+
path: ./var/phpbench/
185+
overwrite: true
186+
187+
publish-website:
188+
name: "Publish Website"
189+
runs-on: ubuntu-latest
190+
strategy:
191+
fail-fast: false
192+
matrix:
193+
php-version:
194+
- "8.2"
195+
196+
steps:
197+
- name: "Checkout"
198+
uses: "actions/checkout@v4"
199+
200+
- name: "Install PHP"
201+
uses: "shivammathur/setup-php@v2"
202+
with:
203+
tools: composer:v2
204+
php-version: "${{ matrix.php-version }}"
205+
ini-values: memory_limit=-1
206+
extensions: :psr, bcmath, dom, hash, json, mbstring, xml, xmlwriter, xmlreader, zlib
207+
208+
- name: "Get Composer Cache Directory"
209+
id: composer-cache
210+
run: |
211+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
212+
213+
- name: "Cache Composer dependencies"
214+
uses: "actions/cache@v4"
215+
with:
216+
path: "${{ steps.composer-cache.outputs.dir }}"
217+
key: "php-${{ matrix.php-version }}-composer-website-${{ hashFiles('web/landing/composer.lock') }}"
218+
restore-keys: |
219+
php-${{ matrix.php-version }}-composer-website-
220+
221+
- name: "Install project dependencies"
222+
run: "composer install --no-interaction --no-progress --no-suggest"
223+
224+
- name: "Generate documentation"
225+
run: "composer build:docs"
226+
227+
- name: "Install Landing dependencies"
228+
run: "composer install --no-interaction --no-progress --no-suggest"
229+
working-directory: "web/landing"
230+
231+
- name: "Build"
232+
run: "composer build"
233+
env:
234+
SCHEME: https
235+
DOMAIN: flow-php.com
236+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
237+
GOOGLE_ANALYTICS_ID: '${{ vars.GOOGLE_ANALYTICS_ID }}'
238+
GOOGLE_CONVERSION_TAG: '${{ vars.GOOGLE_CONVERSION_TAG }}'
239+
working-directory: "web/landing"
240+
241+
- name: Pushes build to website repository
242+
uses: cpina/github-action-push-to-another-repository@main
243+
env:
244+
API_TOKEN_GITHUB: ${{ secrets.ACCESS_TOKEN }}
245+
with:
246+
source-directory: 'web/landing/build'
247+
destination-github-username: 'flow-php'
248+
destination-repository-name: 'flow-php.com'
249+
250+
set-baseline-commit-sha:
251+
runs-on: ubuntu-latest
252+
253+
steps:
254+
- name: Checkout repository
255+
uses: actions/checkout@v3
256+
257+
- name: Fetch specific branch
258+
run: git fetch origin {{ github.event.inputs.branch_name }}
259+
260+
- name: Get the latest commit SHA from the branch
261+
id: get_sha
262+
run: |
263+
branch_sha=$(git rev-parse origin/{{ github.event.inputs.branch_name }})
264+
echo "sha=$branch_sha" >> $GITHUB_ENV
265+
echo "branch_name={{ github.event.inputs.branch_name }}" >> $GITHUB_ENV
266+
267+
- name: Upload commit SHA as artifact
268+
uses: actions/upload-artifact@v3
269+
with:
270+
name: "base-commit-sha-{{ github.event.inputs.branch_name }}"
271+
path: <(echo -n $sha) # Directly pass the SHA

‎.github/workflows/benchmark-baseline.yml‎

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)