Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/staging' into chore/merge-master…
Browse files Browse the repository at this point in the history
…-to-staging-a17s21
  • Loading branch information
darcywong00 committed Sep 15, 2023
2 parents bebcd86 + fc3814f commit a340736
Show file tree
Hide file tree
Showing 577 changed files with 13,164 additions and 12,110 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Treat SVGs like images, and not like text.
*.svg binary
*.svg binary
Dockerfile text eol=lf

112 changes: 23 additions & 89 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,89 +5,23 @@ on: [pull_request]
jobs:

build-test:
runs-on: windows-latest
runs-on: ubuntu-20.04
env:
KEYMANHOSTS_TIER: TIER_TEST

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3.5.2

- name: Setup PHP 7.4
uses: shivammathur/setup-php@6972aed899fa2dd4016a7e314c46e6902bcafb7b
with:
php-version: '7.4'
extensions: curl, intl, mbstring, openssl
coverage: none
# Build the docker image and create link to vendor/ dependencies
- name: Build the Docker image
shell: bash
run: |
echo "TIER_TEST" > tier.txt
./build.sh build start
env:
fail-fast: true

#
# Configure IIS and setup site for running unit tests
# * Installs IIS, CGI extensions, URLRewrite and configures to connect to PHP
# * Sets up http://127.0.0.1:8888 as host for tests
# * Enables detailed error reporting
#
- name: Download and install IIS and setup a local website
shell: powershell
run: |
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServer -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CGI -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIExtensions -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-ISAPIFilter -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-StaticContent -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DefaultDocument -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-CommonHttpFeatures -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpRedirect -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-DirectoryBrowsing -NoRestart
Enable-WindowsOptionalFeature -Online -FeatureName IIS-HttpErrors -NoRestart
choco install --no-progress urlrewrite
Import-Module WebAdministration
New-WebAppPool -name "NewWebSiteAppPool" -force
New-WebSite -name "NewWebSite" -PhysicalPath "$ENV:GITHUB_WORKSPACE" -ApplicationPool "NewWebSiteAppPool" -port 8888 -force
Set-WebConfigurationproperty -filter "system.webServer/httpErrors" -pspath "MACHINE/WEBROOT/APPHOST" -name errorMode -value Detailed
Add-WebConfigurationProperty //defaultDocument/files "IIS:\sites\NewWebSite" -AtIndex 0 -Name collection -Value "index.php"
Add-WebConfigurationProperty //defaultDocument/files "IIS:\sites\NewWebSite" -AtIndex 0 -Name collection -Value "index.md"
mkdir c:\tools\php\tmp
Add-Content -path c:\tools\php\php.ini -value '',"error_log = $ENV:GITHUB_WORKSPACE\php_errors.log","session.save_path = $ENV:GITHUB_WORKSPACE\.phpsessions","error_reporting = E_ALL","display_errors = On","display_startup_errors = On","html_errors = Off","sys_temp_dir = c:\tools\php\tmp"
mkdir $ENV:GITHUB_WORKSPACE\.phpsessions
#
# This step configures FastCGI according to the documentation at https://www.php.net/manual/en/install.windows.manual.php
# This alternative doesn't work: New-WebHandler -name "PHP" -Path *.php -Modules FastCgiModule -ScriptProcessor "c:\tools\php\php-cgi.exe" -Verb 'GET,POST' -Force
#
- name: Setup FastCGI
shell: cmd
run: |
set phpdir=c:\tools
set phppath=php
REM Clear current PHP handlers
%windir%\system32\inetsrv\appcmd clear config /section:system.webServer/fastCGI
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /-[name='PHP_via_FastCGI']
REM Set up the PHP handler
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/fastCGI /+[fullPath='%phpdir%\%phppath%\php-cgi.exe']
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='%phpdir%\%phppath%\php-cgi.exe',resourceType='Unspecified']
%windir%\system32\inetsrv\appcmd set config /section:system.webServer/handlers /accessPolicy:Read,Script
REM Configure FastCGI Variables
%windir%\system32\inetsrv\appcmd set config -section:system.webServer/fastCgi /[fullPath='%phpdir%\%phppath%\php-cgi.exe'].instanceMaxRequests:10000
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phpdir%\%phppath%\php-cgi.exe'].environmentVariables.[name='PHP_FCGI_MAX_REQUESTS',value='10000']"
%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/fastCgi /+"[fullPath='%phpdir%\%phppath%\php-cgi.exe'].environmentVariables.[name='PHPRC',value='%phpdir%\%phppath%\php.ini']"
#
# Install website PHP dependencies
#
- name: Install dependencies
shell: cmd
run: |
echo TIER_TEST > tier.txt
composer install --no-progress
npm install
#
# Finally, run the tests
#
Expand All @@ -99,22 +33,22 @@ jobs:
- name: Check broken links
shell: bash
run: |
( set +e; set +o pipefail; npx broken-link-checker http://localhost:8888 --ordered --recursive --host-requests 50 -e --filter-level 3 | grep -E "BROKEN|Getting links from" | grep -B 1 "BROKEN"; exit ${PIPESTATUS[0]} )
set +e;
set +o pipefail;
npx broken-link-checker http://localhost:8055 --ordered --recursive --host-requests 50 -e --filter-level 3 | \
grep -E "BROKEN|Getting links from" | \
grep -B 1 "BROKEN"
exit ${PIPESTATUS[0]}
- name: Check PHP errors
shell: bash
run: |
( set +e; set +o pipefail; [ -f php_errors.log ] && echo 'PHP reported errors or warnings; see log below' && exit 1 || ( echo 'No PHP errors found' && exit 0 ) )
#
# If any of the tests fail, let's grab a bit more detail on the environment
#
- name: Report errors
if: ${{ failure() }}
shell: bash
run: |
echo "--- tier.txt ---"
cat tier.txt
echo "--- PHP Errors ---"
[ -f php_errors.log ] && cat php_errors.log
echo "--- PHPInfo ---"
php -r 'phpinfo();'
CONTAINER=`docker container ls -l -q`
if docker container logs $CONTAINER 2>&1 | grep -q 'php7'; then
echo 'PHP reported errors or warnings:'
docker container logs $CONTAINER 2>&1 | grep 'php7'
exit 1
else
echo 'No PHP errors found'
exit 0
fi
21 changes: 21 additions & 0 deletions .github/workflows/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Prune images
on:
workflow_run:
workflows: [Docker-build]
types: [completed]

jobs:
prune:
runs-on: ubuntu-latest
steps:
- name: prune
uses: vlaurin/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
organization: keymanapp
container: help-keyman-com
dry-run: false
keep-younger-than: 7
keep-last: 3
prune-tags-regexes: ^.*$
prune-untagged: true
61 changes: 61 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Docker-build
on:
push:
branches: [ "master", "staging" ]
paths:
- Dockerfile
- composer.*
- resources/**
- .github/**
env:
REGISTRY: ghcr.io
IMAGE_NAME: keymanapp/help-keyman-com

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

# Login against a Docker registry except on PR
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{branch}}
type=raw,value=latest
labels: |
org.opencontainers.image.description=PHP api runtime
# Build and push Docker image with Buildx (don't push on PR)
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v4
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
**/.DS_Store
.idea/
cdn/deploy
vendor/
vendor*
.vscode/
node_modules/
Loading

0 comments on commit a340736

Please sign in to comment.