Skip to content

Commit

Permalink
Setup CI/CD for website (#962)
Browse files Browse the repository at this point in the history
* Setup CI/CD for website

* CS Fixes

* Updated readme

* Fixed failing tests

* Removed build foler from repo:

* Added action to pulish website
  • Loading branch information
norberttech authored Feb 4, 2024
1 parent 03dd915 commit e1b3071
Show file tree
Hide file tree
Showing 12 changed files with 523 additions and 48 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Publish Website

on:
workflow_dispatch:
push:
branches: [ 1.x ]

jobs:
publish-website:
name: "Publish Website"

runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
tools: composer:v2
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
extensions: :psr

- name: "Get Composer Cache Directory"
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: "Cache Composer dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: "php-${{ matrix.php-version }}-composer-website-${{ hashFiles('web/landing/composer.lock') }}"
restore-keys: |
php-${{ matrix.php-version }}-composer-website-
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress --no-suggest"
working-directory: "web/landing"

- name: "Build"
run: "composer build"
working-directory: "web/landing"

- name: Pushes build to website repository
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.ACCESS_TOKEN }}
with:
source-directory: 'web/landing/build'
destination-github-username: 'flow-php'
destination-repository-name: 'website'
51 changes: 49 additions & 2 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- 'src/adapter/**'
- 'src/core/**'
- 'src/lib/**'
- 'web/**'
- 'tools/**'
- 'composer.lock'
push:
Expand Down Expand Up @@ -170,7 +171,6 @@ jobs:
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: pcov
tools: composer:v2
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
Expand Down Expand Up @@ -215,4 +215,51 @@ jobs:
FLOW_LOCAL_FILESYSTEM_CACHE_DIR: "./var/cache/${{ matrix.php-version }}-${{ matrix.dependencies }}"

- name: "Run Examples"
run: "php examples/run.php"
run: "php examples/run.php"

website-tests:
name: "Website Tests"

runs-on: ${{ matrix.operating-system }}

strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: "actions/checkout@v4"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: pcov
tools: composer:v2
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
extensions: :psr

- name: "Get Composer Cache Directory"
id: composer-cache
run: |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: "Cache Composer dependencies"
uses: "actions/cache@v3"
with:
path: "${{ steps.composer-cache.outputs.dir }}"
key: "php-${{ matrix.php-version }}-composer-website-${{ hashFiles('web/landing/composer.lock') }}"
restore-keys: |
php-${{ matrix.php-version }}-composer-website-
- name: "Install dependencies"
run: "composer install --no-interaction --no-progress --no-suggest"
working-directory: "web/landing"

- name: "Test"
run: "composer test"
working-directory: "web/landing"
1 change: 1 addition & 0 deletions web/landing/.php-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.1
7 changes: 7 additions & 0 deletions web/landing/.symfony.local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
workers:
tailwind:
cmd: ['symfony', 'console', 'tailwind:build', '--watch']

proxy:
domains:
- "flow-php"
39 changes: 12 additions & 27 deletions web/landing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,27 @@ To run web page locally, you need to have Symfony CLI installed locally.
Instruction on how to install it can be found here: [https://symfony.com/download](https://symfony.com/download).

## Setup
Install all dependencies:
```shell
composer install
```

Create a local certificate authority for the server:
```shell
composer install
symfony server:ca:install
symfony server:start -d
```

Run symfony web server:
```shell
symfony server:start --dir=public -d
```
To use [https://flow-php.wip](https://flow-php.wip) you need to [configure local proxy](https://symfony.com/doc/current/setup/symfony_server.html#setting-up-the-local-proxy).
Otherwise, you can use [https://127.0.0.1:800X](https://127.0.0.1:8000);

Build assets:
```shell
bin/console tailwind:build
## Building Static Content

```
comoser build
```

Page will be accessible from [https://127.0.0.1:8000](https://127.0.0.1:8000) url.
Before opening a pull request, please verify if the build is successful:

To stop symfony web server, execute:
```shell
symfony local:server:stop --dir=public
```

## Working with CSS using Tailwind
We strive to eliminate usage of Node and NPM in Flow PHP, so we decided to use standalone CLI executable here.
To generated CSS using Tailwind, execute:
```shell
bin/console tailwind:build
php -S localhost:9000 -t build
```

It'll fetch executable file and create CSS that will be served from web server.
Or if you want to keep it running in the watch mode, execute:
```shell
bin/console tailwind:build --watch
```
Open: [https://localhost:9000](https://localhost:9000)

31 changes: 26 additions & 5 deletions web/landing/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
"symfony/console": "^6.4",
"symfony/yaml": "^6.4",
"symfony/dotenv": "^6.4",
"symfony/stimulus-bundle": "^2.14"
"symfony/stimulus-bundle": "^2.14",
"monolog/monolog": "^3.5",
"symfony/monolog-bundle": "^3.10"
},
"require-dev": {
"symfony/web-profiler-bundle": "^6.4",
Expand All @@ -43,18 +45,37 @@
}
},
"scripts": {
"post-install-cmd": [
"@importmap:install",
"@build:tailwind",
"@tools:install"
],
"post-update-cmd": [
"@importmap:install",
"@build:tailwind",
"@tools:update"
],
"tools:install": [
"composer install --working-dir=./tools/phpunit"
],
"test": [
"tools/phpunit/vendor/bin/phpunit"
],
"assets:clear": "rm -rf public/assets",
"assets:build": [
"importmap:install": "bin/console importmap:install",
"build:assets": [
"@assets:clear",
"bin/console tailwind:build",
"@importmap:install",
"@build:tailwind",
"bin/console asset-map:compile"
],
"build:tailwind": [
"bin/console tailwind:build"
],
"build": [
"bin/console static-content-generator:generate:routes",
"bin/console static-content-generator:copy:assets -d assets"
"@build:assets",
"bin/console static-content-generator:generate:routes --clean",
"bin/console static-content-generator:copy:assets -d public"
]
}
}
Loading

0 comments on commit e1b3071

Please sign in to comment.