Skip to content

Commit 9a2ba89

Browse files
authored
Merge pull request #4 from prosopo/main
Simple Membership
2 parents 92000e7 + 30467e4 commit 9a2ba89

File tree

372 files changed

+9096
-3880
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

372 files changed

+9096
-3880
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Initial Setup
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Print initial state
7+
run: |
8+
echo -e "GitHub workspace:${{ github.workspace }}"
9+
echo "Current directory:"
10+
pwd
11+
echo "Contents of /etc/hosts:"
12+
cat /etc/hosts
13+
echo "Owner of /etc/hosts:"
14+
ls -l /etc/hosts
15+
echo "Current user:"
16+
whoami
17+
shell: bash
18+
19+
- name: Install Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '22'
23+
24+
# 8.2+ is expected for php-code-quality-tests
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: '8.2'
29+
extensions: mbstring, opcache
30+
31+
- name: Install Composer
32+
run: |
33+
curl -sS https://getcomposer.org/installer | php
34+
sudo mv composer.phar /usr/local/bin/composer
35+
shell: bash
36+
37+
- name: Run install-tools.sh
38+
run: bash ${{ github.workspace }}/tools/install-tools.sh
39+
shell: bash
40+
41+
- name: Build assets
42+
run: cd ${{ github.workspace }}/assets && yarn build:all
43+
shell: bash
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: SVN Make Commit
2+
3+
inputs:
4+
username:
5+
description: "SVN account username to make a commit"
6+
required: true
7+
password:
8+
description: "SVN account password to make a commit"
9+
required: true
10+
tag:
11+
description: "Current release tag"
12+
required: true
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Handle removed items in the trunk folder
18+
run: |
19+
# Check for removed files and handle them
20+
REMOVED_FILES=$(svn status | awk '/^\!/ {print $2}')
21+
if [ -n "$REMOVED_FILES" ]; then
22+
echo "Found removed files:"
23+
echo "$REMOVED_FILES"
24+
echo "$REMOVED_FILES" | sort -r | xargs -r svn delete
25+
else
26+
echo "No removed files to handle."
27+
fi
28+
working-directory: ${{ github.workspace }}/release/trunk
29+
shell: bash
30+
31+
- name: Add new folders and files
32+
run: |
33+
svn add --force ${{ github.workspace }}/release/trunk
34+
svn add --force ${{ github.workspace }}/release/assets/*
35+
svn add ${{ github.workspace }}/release/tags/${{ inputs.tag }}
36+
shell: bash
37+
38+
- name: Commit changes
39+
run: |
40+
cd ${{ github.workspace }}/release
41+
svn ci -m "v ${{ inputs.tag }}" --config-option=servers:global:http-timeout=900 --non-interactive --no-auth-cache --username ${{ inputs.username }} --password ${{ inputs.password }}
42+
shell: bash
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: SVN Prepare Commit
2+
3+
outputs:
4+
release_tag:
5+
description: "Current release tag"
6+
value: ${{ steps.get_tag.outputs.version }}
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Get tag
12+
id: get_tag
13+
run: |
14+
VERSION="${GITHUB_REF#refs/tags/}"
15+
VERSION="${VERSION#v}"
16+
echo "::set-output name=version::$VERSION"
17+
shell: bash
18+
19+
- name: Print tag
20+
run: |
21+
echo "Tag: ${{ steps.get_tag.outputs.version }}"
22+
shell: bash
23+
24+
- name: Make release folder
25+
run: mkdir ${{ github.workspace }}/release
26+
shell: bash
27+
28+
- name: Init SVN
29+
run: svn co https://plugins.svn.wordpress.org/prosopo-procaptcha ${{ github.workspace }}/release
30+
shell: bash
31+
32+
- name: Make sure the tag does not exist
33+
run: |
34+
set -e # Exit immediately if a command exits with a non-zero status
35+
cd ${{ github.workspace }}/release
36+
# Check if the tag already exists
37+
if svn ls tags | grep -q ${{ steps.get_tag.outputs.version }}; then
38+
echo "Tag ${{ steps.get_tag.outputs.version }} already exists."
39+
exit 1
40+
else
41+
echo "Tag ${{ steps.get_tag.outputs.version }} does not exist."
42+
fi
43+
shell: bash
44+
45+
- name: Copy assets
46+
run: cp ${{ github.workspace }}/wordpress-org-assets/* ${{ github.workspace }}/release/assets
47+
shell: bash
48+
49+
- name: Create the target Tag folder
50+
run: mkdir ${{ github.workspace }}/release/tags/${{ steps.get_tag.outputs.version }}
51+
shell: bash
52+
53+
- name: Copy files to the new Tag folder
54+
run: cp -r ${{ github.workspace }}/prosopo-procaptcha/* ${{ github.workspace }}/release/tags/${{ steps.get_tag.outputs.version }}
55+
shell: bash
56+
57+
- name: Empty Trunk folder
58+
run: rm ${{ github.workspace }}/release/trunk/* -rf
59+
shell: bash
60+
61+
- name: Copy files and folders to the Trunk folder
62+
run: cp -r ${{ github.workspace }}/prosopo-procaptcha/* ${{ github.workspace }}/release/trunk
63+
shell: bash
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Clone Private Repository
2+
3+
inputs:
4+
private_folder:
5+
description: "Target folder the private repo should be extract to"
6+
required: true
7+
private_repo:
8+
description: "Repo with paid plugin archives"
9+
required: true
10+
private_key:
11+
description: "Private SSH key to access the private repository"
12+
required: true
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Clone Private Plugin Repository
18+
run: |
19+
mkdir -p ${{ inputs.private_folder }}
20+
cd ${{ inputs.private_folder }}
21+
22+
# Setup SSH Key for Private Repo Access
23+
mkdir -p ~/.ssh
24+
echo "${{ inputs.private_key }}" > ~/.ssh/id_ed25519
25+
chmod 600 ~/.ssh/id_ed25519
26+
ssh-keyscan -t ed25519 github.com >> ~/.ssh/known_hosts
27+
28+
# Clone the Private Repository
29+
git clone [email protected]:${{ inputs.private_repo }} .
30+
shell: bash
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Install E2E Packages
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
# we need to install PHP 7.4 separately from php 8.2 in the initial-setup,
7+
# cause WordPress is compatible with PHP 7.4
8+
- name: Install PHP 7.4
9+
uses: shivammathur/setup-php@v2
10+
with:
11+
php-version: '7.4'
12+
extensions: mbstring, mysqli, opcache
13+
14+
- name: Install Nginx
15+
run: sudo apt-get update && sudo apt-get install -y nginx
16+
shell: bash
17+
18+
- name: Install MySQL client
19+
run: sudo apt-get update && sudo apt-get install -y mysql-client
20+
shell: bash
21+
22+
# cypress dependencies https://docs.cypress.io/guides/getting-started/installing-cypress#Linux-Prerequisites
23+
- name: Install cypress dependencies
24+
run: sudo apt-get update && sudo apt-get install -y libgtk2.0-0t64 libgtk-3-0t64 libgbm-dev libnotify-dev libnss3 libxss1 libasound2t64 libxtst6 xauth xvfb
25+
shell: bash
26+
27+
- name: Install Chrome
28+
run: |
29+
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
30+
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
31+
sudo apt-get update
32+
sudo apt-get install -y google-chrome-stable
33+
shell: bash
34+
35+
# used in the tasks/install-wordpress-with-plugins.yml
36+
- name: Install JSON parser
37+
run: sudo apt-get update && sudo apt-get install -y jq
38+
shell: bash
39+
40+
# used in the /tests.yml
41+
- name: Install wait-on
42+
run: npm install -g wait-on
43+
shell: bash
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Install WordPress with Plugins
2+
3+
inputs:
4+
paid_plugins_dir:
5+
description: "Folder with archives for the paid plugins"
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Download and setup WordPress
12+
run: |
13+
cd ${{ github.workspace }}
14+
curl -O https://wordpress.org/latest.tar.gz
15+
tar -xzf latest.tar.gz
16+
mv wordpress/* ${{ github.workspace }}
17+
cp wp-config-sample.php wp-config.php
18+
sed -i "s/database_name_here/wordpress/" wp-config.php
19+
sed -i "s/username_here/root/" wp-config.php
20+
sed -i "s/password_here/wordpress/" wp-config.php
21+
sed -i "s/localhost/127.0.0.1/" wp-config.php
22+
sed -i "s/define( 'WP_DEBUG', false );/define( 'WP_DEBUG', true );\ndefine( 'WP_DEBUG_DISPLAY', false );\ndefine( 'WP_DEBUG_LOG', true );error_reporting( E_ALL );/" wp-config.php
23+
cp -r ${{ github.workspace }}/prosopo-procaptcha ${{ github.workspace }}/wp-content/plugins/
24+
mkdir -p ${{ github.workspace }}/wp-content/mu-plugins
25+
cp ${{ github.workspace }}/data-for-tests/mu-plugin.php ${{ github.workspace }}/wp-content/mu-plugins/mu-plugin.php
26+
shell: bash
27+
28+
- name: Install WordPress plugins
29+
run: |
30+
cd ${{ github.workspace }}/tests/cypress/e2e/${{ matrix.cypress-target }}
31+
plugins=$(cat ./installation-list.json | jq -r '.plugins[]')
32+
for plugin in $plugins; do
33+
echo "Installing $plugin plugin"
34+
35+
paid_plugin_path="${{ inputs.paid_plugins_dir }}/$plugin.zip"
36+
37+
if [[ -f "$paid_plugin_path" ]]; then
38+
echo "Found paid plugin ZIP for $plugin in the paid plugins directory."
39+
unzip "$paid_plugin_path" -d ${{ github.workspace }}/wp-content/plugins/
40+
else
41+
echo "No local ZIP for $plugin, downloading from WordPress repository."
42+
curl -L -o "$plugin.zip" "https://downloads.wordpress.org/plugin/$plugin.latest-stable.zip"
43+
unzip "$plugin.zip" -d ${{ github.workspace }}/wp-content/plugins/
44+
rm "$plugin.zip"
45+
fi
46+
done
47+
shell: bash
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Prepare E2E Workflow
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Move website files to /var/www/procaptcha
7+
run: sudo mv ${{ github.workspace }}/* /var/www/procaptcha
8+
shell: bash
9+
10+
# it's necessary, as cypress was installed under the 'runner' user, so these folders should left.
11+
- name: Back tests and tools folders
12+
run: |
13+
sudo mv /var/www/procaptcha/tests ${{ github.workspace }}
14+
sudo mv /var/www/procaptcha/tools ${{ github.workspace }}
15+
shell: bash
16+
17+
- name: Set ownership of website files to www-data
18+
run: sudo chown -R www-data:www-data /var/www/procaptcha
19+
shell: bash
20+
21+
- name: Wait for WordPress to start
22+
run: npx wait-on http://procaptcha.local --timeout 10000
23+
shell: bash
24+
25+
- name: Check domain resolution
26+
run: curl -I http://procaptcha.local
27+
shell: bash
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Setup E2E Packages
2+
3+
runs:
4+
using: "composite"
5+
steps:
6+
# note when using act, it uses copy of your '/etc/hosts', so it's important to override it instead of appending
7+
- name: Override /etc/hosts
8+
run: echo "127.0.0.1 localhost procaptcha.local" | sudo tee /etc/hosts
9+
shell: bash
10+
11+
- name: Configure Nginx
12+
run: |
13+
sudo bash -c 'cat > /etc/nginx/sites-available/default <<EOF
14+
server {
15+
listen 80;
16+
server_name localhost procaptcha.local;
17+
18+
root /var/www/procaptcha;
19+
index index.php index.html index.htm;
20+
21+
location / {
22+
try_files \$uri \$uri/ /index.php?\$args;
23+
}
24+
25+
location ~ \.php$ {
26+
include snippets/fastcgi-php.conf;
27+
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
28+
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
29+
include fastcgi_params;
30+
}
31+
}
32+
EOF'
33+
shell: bash
34+
35+
# it's necessary step, as www-data from nginx has no access to the /home/runner/work/* folder
36+
- name: Create procaptcha web directory
37+
run: sudo mkdir /var/www/procaptcha && sudo chown -R www-data:www-data /var/www/procaptcha
38+
shell: bash
39+
40+
- name: Start Nginx
41+
run: sudo service nginx start
42+
shell: bash
43+
44+
- name: Start PHP-FPM
45+
run: sudo service php7.4-fpm start
46+
shell: bash
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release New Version
2+
3+
on:
4+
push:
5+
tags:
6+
# 1.0.0
7+
- '[0-9]+\.[0-9]+\.[0-9]+'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Initial setup
18+
uses: ./.github/actions/initial-setup
19+
20+
- name: Make sure SVN_USERNAME and SVN_PASSWORD are present
21+
run: |
22+
if [ -z "${{ secrets.SVN_USERNAME }}" ]; then
23+
echo "Set the SVN_USERNAME secret"
24+
exit 1
25+
fi
26+
if [ -z "${{ secrets.SVN_PASSWORD }}" ]; then
27+
echo "Set the SVN_PASSWORD secret"
28+
exit 1
29+
fi
30+
31+
- name: Install Subversion
32+
run: sudo apt-get update && sudo apt-get install -y subversion
33+
34+
- name: SVN prepare commit
35+
id: svn_commit_preparation
36+
uses: ./.github/actions/release/svn-prepare-commit
37+
38+
- name: SVN make commit
39+
uses: ./.github/actions/release/svn-make-commit
40+
with:
41+
username: ${{ secrets.SVN_USERNAME }}
42+
password: ${{ secrets.SVN_PASSWORD }}
43+
tag: ${{ steps.svn_commit_preparation.outputs.release_tag }}

0 commit comments

Comments
 (0)