Skip to content

Commit

Permalink
feat!: refactoring (merge pull request #15 from helsingborg-stad/feat…
Browse files Browse the repository at this point in the history
…/link-not-avabile)

feat!: refactoring
  • Loading branch information
sebastianthulin authored Nov 14, 2024
2 parents 21a1017 + 46f70a4 commit 55e48ae
Show file tree
Hide file tree
Showing 127 changed files with 5,824 additions and 5,653 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# WordPress version can be any of the listed tags from https://hub.docker.com/_/wordpress/tags
# E.g. latest, 6.2, ...
ARG WORDPRESS_VERSION=latest

# PHP Variant can be any of the listed tags from https://mcr.microsoft.com/v2/devcontainers/php/tags/list
ARG PHP_VARIANT=8.3-bullseye

FROM wordpress:${WORDPRESS_VERSION}
FROM mcr.microsoft.com/vscode/devcontainers/php:${PHP_VARIANT}

# Copy WordPress files from wordpress container.
COPY --from=0 /usr/src/wordpress/ /var/www/html/

# Make vscode owner of all WordPress files.
RUN chown -R vscode:vscode /var/www/html

# Install php-mysql driver
RUN docker-php-ext-install mysqli pdo pdo_mysql

# Install additional packages for running e2e tests
RUN apt-get update && \
apt-get install -y subversion && \
apt-get install -y default-mysql-client

# Enable apache mods
RUN a2enmod rewrite expires

# Install WP-CLI
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar && chmod +x wp-cli.phar && sudo mv wp-cli.phar /usr/local/bin/wp
1 change: 1 addition & 0 deletions .devcontainer/config/_.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MUNICIPIO_ACF_PRO_KEY=b3JkZXJfaWQ9ODE2NDZ8dHlwZT1kZXZlbG9wZXJ8ZGF0ZT0yMDE2LTA1LTE2IDExOjEyOjQ4
58 changes: 58 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb
{
"name": "PHP & MySQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"forwardPorts": [
80,
3306
],
"portsAttributes": {
"80": {
"label": "WordPress"
},
"3306": {
"label": "Database"
}
},
"remoteEnv": {
"XDEBUG_MODE": "off"
},
"customizations": {
"vscode": {
"extensions": [
"xdebug.php-debug",
"ms-azuretools.vscode-docker",
"ritwickdey.liveserver"
],
"settings": {
"intelephense.environment.includePaths": [
"/var/www/html",
"/tmp/wordpress-tests-lib/includes"
],
"intelephense.environment.phpVersion": "8.3"
}
}
},
"features": {
"ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
"packages": "curl,nano,bash-completion",
"upgradePackages": true
},
"ghcr.io/devcontainers/features/node:1": {
"nodeGypDependencies": true,
"version": "16"
}
},
"postCreateCommand": {
"symlink-plugin": "ln -s \"$(pwd)\" \"/var/www/html/wp-content/plugins/$(basename \"$PWD\")\"",
"symlink-wp-config-local": "ln -s \"$(pwd)/.devcontainer/wp-config-local.php\" /var/www/html/wp-config-local.php",
"symlink-wp-config": "ln -s \"$(pwd)/.devcontainer/wp-config.php\" /var/www/html/wp-config.php",
"start-apache": "service apache2 start",
"setup-e2e-tests": "composer test:setup:e2e"
},
"waitFor": "postCreateCommand",
"remoteUser": "vscode"
}
37 changes: 37 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: '3.8'

services:
app:
# env_file: devcontainer.env
build:
context: .
dockerfile: Dockerfile

volumes:
- ../..:/workspaces:cached

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db

# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: mariadb:10.4
restart: always
volumes:
- db-data:/var/lib/mysql
environment:
MYSQL_DATABASE: dev
MYSQL_ROOT_PASSWORD: dev
MYSQL_USER: dev
MYSQL_PASSWORD: dev

# Add "forwardPorts": ["3306"] to **devcontainer.json** to forward MariaDB locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

volumes:
db-data:
106 changes: 106 additions & 0 deletions .devcontainer/wp-config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the web site, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://wordpress.org/documentation/article/editing-wp-config-php/
*
* @package WordPress
*/

if (file_exists(__DIR__ . '/wp-config-local.php')) {
require __DIR__ . '/wp-config-local.php';
}

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
if (!defined('DB_NAME')) define('DB_NAME', 'dev');

/** Database username */
if (!defined('DB_USER')) define('DB_USER', 'dev');

/** Database password */
if (!defined('DB_PASSWORD')) define('DB_PASSWORD', 'dev');

/** Database hostname */
if (!defined('DB_HOST')) define('DB_HOST', 'db');

/** Database charset to use in creating database tables. */
if (!defined('DB_CHARSET')) define('DB_CHARSET', 'utf8mb4');

/** The database collate type. Don't change this if in doubt. */
if (!defined('DB_COLLATE')) define('DB_COLLATE', '');

if (!defined('WP_SITEURL')) define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] ?? 'localhost');
if (!defined('WP_HOME')) define('WP_HOME', WP_SITEURL);
if (!defined('WP_CONTENT_URL')) define('WP_CONTENT_URL', WP_SITEURL . '/wp-content');

/**#@+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* @since 2.6.0
*/
define('AUTH_KEY', '(J.hL1=7inY7O%xo.1K^b1*=NQ!AvkBfq>HHW}D6T#6ktdvZ4qMpm7OW+vR:pHxm');
define('SECURE_AUTH_KEY', 'pPwN{M1g=?j`me{7rE-7OtJN$zDS(y#uM7.1~.X~>m+#/ln~%Myo$Ca2mBFEa0s:');
define('LOGGED_IN_KEY', '8-AQ.XlAXQTq8:f2ddzxIs]xeC cE`ZdvAv9S=*bg>I~bHT/jGLyXW4=)!rhjz+g');
define('NONCE_KEY', '9{1MgwMd|^-i3OIy(`4jmEk5T/%1Q_i^bB&h%Jc7: :m]Ic7e&fkc=8YV_2|A~Fs');
define('AUTH_SALT', 'P(}]`j]rI]Rzd<NTP`1A|aNg`)I&5cNjxZ3cb,C]PDRFeOgys@?}lV)8omoqq|UZ');
define('SECURE_AUTH_SALT', 'r./W6cc]R;#&[Isz7$`<G@4UM0qIe|mLwu;kZzG:o@[T^ML&QyN!K!Lb88X3n{<h');
define('LOGGED_IN_SALT', 'R:O%d{!<Ua/sf9zc6/^G;I*!+,&<UFgJ&hD r6GZ]x@Q[j#;&;X&&JQdJG~eqN1[');
define('NONCE_SALT', '^G^t@e9n!ys-{?yz V9&U2zCsyEVI_P3C4>S*{U]Y#(n~NzR|*Xx)6{0*/kvY^pc');

/**#@-*/

/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
if (!isset($table_prefix)) $table_prefix = 'wp_';

/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/documentation/article/debugging-in-wordpress/
*/
define('WP_DEBUG', true);
if (!defined('WP_DEBUG')) define('WP_DEBUG', false);

define('WP_DEBUG_LOG', true);

/* Add any custom values between this line and the "stop editing" line. */



/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if (!defined('ABSPATH')) define('ABSPATH', __DIR__ . '/');

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
50 changes: 50 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build assets and create a release on version tags

on:
push:
tags:
- 'v*.*.*'
jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: '16'

- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer:v2

- name: Inject access token in .npmrc
run: |
echo "registry=https://npm.pkg.github.com/helsingborg-stad" >> ~/.npmrc
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" >> ~/.npmrc
- name: Run full build.
run: php ./build.php --cleanup

- name: Cleanup .npmrc
run: rm ~/.npmrc

- name: Archive Release
uses: thedoctor0/zip-release@master
with:
filename: 'full-release.zip'

- name: Release
uses: docker://antonyurchenko/git-release:latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRAFT_RELEASE: "false"
PRE_RELEASE: "false"
CHANGELOG_FILE: "none"
with:
args: |
full-release.zip
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Create Release and bump version files
uses: helsingborg-stad/[email protected]
with:
php-version: 8.2
php-version: 8.3
node-version: 20.6.0
build-assets:
needs: ['release']
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20.6.0
node-version: 20
- name: Inject access token in .npmrc
run: |
echo "registry=https://npm.pkg.github.com/helsingborg-stad" >> ~/.npmrc
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
if: ${{ hashFiles('composer.json') != '' }}
with:
tools: composer
php-version: '7.4'
php-version: '8.3'

- name: Build PHP
if: ${{ hashFiles('composer.json') != '' }}
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/test-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test JS

on:
push:
branches: [ 3.0/develop, master ]
pull_request:
branches: [ 3.0/develop, master ]

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
29 changes: 29 additions & 0 deletions .github/workflows/test-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test:PHP

on:
pull_request:

jobs:

test:

runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP with composer v2
uses: shivammathur/setup-php@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
php-version: '8.2'
tools: composer:v2

- name: Install dependencies
run: composer i

- name: Run tests
run: composer test
Loading

0 comments on commit 55e48ae

Please sign in to comment.