Skip to content

Commit

Permalink
Merge branch 'main' into refactor/default-php-8-2
Browse files Browse the repository at this point in the history
Signed-off-by: Philipp Bammes <[email protected]>
  • Loading branch information
tyrann0us authored Sep 30, 2024
2 parents 3735857 + 1d33ebd commit 04d6ff0
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 106 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/static-analysis-js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Static code analysis JavaScript

on:
workflow_call:
inputs:
NPM_REGISTRY_DOMAIN:
description: Domain of the private npm registry.
default: https://npm.pkg.github.com/
required: false
type: string
NODE_VERSION:
description: Node version with which the static analysis is to be executed.
default: 18
required: false
type: string
NODE_OPTIONS:
description: Space-separated list of command-line Node options.
type: string
default: ''
required: false
secrets:
NPM_REGISTRY_TOKEN:
description: Authentication for the private npm registry.
required: false
GITHUB_USER_EMAIL:
description: Email address for the GitHub user configuration.
required: false
GITHUB_USER_NAME:
description: Username for the GitHub user configuration.
required: false
GITHUB_USER_SSH_KEY:
description: Private SSH key associated with the GitHub user passed as `GITHUB_USER_NAME`.
required: false
ENV_VARS:
description: Additional environment variables as a JSON formatted object.
required: false

jobs:
static-analysis-js:
timeout-minutes: 5
runs-on: ubuntu-latest
env:
NODE_OPTIONS: ${{ inputs.NODE_OPTIONS }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
NODE_CACHE_MODE: ''
GITHUB_USER_EMAIL: ${{ secrets.GITHUB_USER_EMAIL }}
GITHUB_USER_NAME: ${{ secrets.GITHUB_USER_NAME }}
GITHUB_USER_SSH_KEY: ${{ secrets.GITHUB_USER_SSH_KEY }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up custom environment variables
env:
ENV_VARS: ${{ secrets.ENV_VARS }}
if: ${{ env.ENV_VARS }}
uses: actions/github-script@v7
with:
script: |
JSON
.parse(process.env.ENV_VARS)
.forEach(envVar => core.exportVariable(envVar.name, envVar.value));
- name: Set up SSH
if: ${{ env.GITHUB_USER_SSH_KEY != '' }}
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }}

- name: Set up Git
run: |
git config --global user.email "${{ env.GITHUB_USER_EMAIL }}"
git config --global user.name "${{ env.GITHUB_USER_NAME }}"
- name: Set up node cache mode
run: |
if [ -f "${GITHUB_WORKSPACE}/package-lock.json" ] || [ -f "${GITHUB_WORKSPACE}/npm-shrinkwrap.json" ]; then
echo "NODE_CACHE_MODE=npm" >> $GITHUB_ENV
else
echo "No lock files found"
fi
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.NODE_VERSION }}
registry-url: ${{ inputs.NPM_REGISTRY_DOMAIN }}
cache: ${{ env.NODE_CACHE_MODE }}

- name: Install dependencies
env:
ARGS: ${{ env.NODE_CACHE_MODE == 'npm' && 'ci' || 'install' }}
run: ${{ format('npm {0}', env.ARGS) }}

- name: Run tsc
run: ./node_modules/.bin/tsc --noEmit --skipLibCheck --pretty false
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ With [GitHub Actions](https://github.com/features/actions), you can create custo
software development lifecycle directly in your GitHub repository. These workflows consist of
different tasks, called actions, that can be executed automatically when certain events occur.

At Syde, we use GitHub Actions for a wide range of tasks. From various quality assurance tests
(e.g. static analysis checks, PHPUnit tests, etc.), to asset (pre)compilation
At Syde, we use GitHub Actions for a wide range of tasks. From various quality assurance tests (
e.g., static analysis checks, PHPUnit tests, etc.), to asset (pre)compilation
with [Composer Asset Compiler](https://github.com/inpsyde/composer-asset-compiler), release
generation, deployments (CI/CD), and container registry management: all automatable, recurring tasks
are performed in GitHub Actions.
Expand Down
12 changes: 7 additions & 5 deletions docs/archive-creation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Create plugin archive

This action can be used to create plugin archives in a controlled and isolated environment via GitHub Actions.
This action can be used to create plugin archives in a controlled and isolated environment via
GitHub Actions.

To achieve that, the reusable workflow:

Expand All @@ -11,7 +12,8 @@ To achieve that, the reusable workflow:
5. Executes Rector if configured by the package
6. Re-installs dependencies without dev-dependencies
7. Sets current commit hash and plugin version in the plugin's main file
8. Runs `wp dist-archive` to create the final archive (with builtin support for a `.distignore` file)
8. Runs `wp dist-archive` to create the final archive (with builtin support for a `.distignore`
file)
9. Uploads it as an artifact for download or further processing

## Simple usage example
Expand Down Expand Up @@ -60,9 +62,9 @@ jobs:
#### A note on `PLUGIN_VERSION`

The workflow will accept any arbitrary string and will use it without validation or sanitization.
Adding this would mean reduced flexibility at increased complexity. Adding standardization/validation
is encouraged but should take place in the controlling workflow, where the conventions and requirements
of the project/team/client are known.
Adding this would mean reduced flexibility at increased complexity. Adding
standardization/validation is encouraged but should take place in the controlling workflow, where
the conventions and requirements of the project/team/client are known.

## Secrets

Expand Down
21 changes: 11 additions & 10 deletions docs/assets-compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

This workflow utilizes
the [Composer Asset Compiler](https://github.com/inpsyde/composer-asset-compiler) to compile assets.
For details, refer to [Pre-compilation](https://github.com/inpsyde/composer-asset-compiler#pre-compilation).
For details, refer
to [Pre-compilation](https://github.com/inpsyde/composer-asset-compiler#pre-compilation).

**Simplest possible example:**

Expand All @@ -20,15 +21,15 @@ jobs:
### Inputs
| Name | Default | Description |
|-----------------------|-------------------------------|-----------------------------------------------------------------------------------|
| `NODE_OPTIONS` | `''` | Space-separated list of command-line Node options |
| `NODE_VERSION` | `18` | Node version with which the assets will be compiled |
| `NPM_REGISTRY_DOMAIN` | `https://npm.pkg.github.com/` | Domain of the private npm registry |
| `PACKAGE_MANAGER` | `yarn` | Package manager with which the dependencies should be installed (`npm` or `yarn`) |
| `PHP_VERSION` | `'8.2'` | PHP version with which the assets compilation is to be executed |
| `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer |
| `COMPILE_ASSETS_ARGS` | `'-v --env=root'` | Set of arguments passed to Composer Asset Compiler |
| Name | Default | Description |
|-----------------------|---------------------------------|-----------------------------------------------------------------------------------|
| `NODE_OPTIONS` | `''` | Space-separated list of command-line Node options |
| `NODE_VERSION` | `18` | Node version with which the assets will be compiled |
| `NPM_REGISTRY_DOMAIN` | `'https://npm.pkg.github.com/'` | Domain of the private npm registry |
| `PACKAGE_MANAGER` | `'yarn'` | Package manager with which the dependencies should be installed (`npm` or `yarn`) |
| `PHP_VERSION` | `'8.2'` | PHP version with which the assets compilation is to be executed |
| `COMPOSER_ARGS` | `'--prefer-dist'` | Set of arguments passed to Composer |
| `COMPILE_ASSETS_ARGS` | `'-v --env=root'` | Set of arguments passed to Composer Asset Compiler |

### Secrets

Expand Down
23 changes: 12 additions & 11 deletions docs/automatic-release.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# Automatic release

This workflow utilizes [semantic-release](https://github.com/semantic-release/semantic-release) to create a package
release.
Note that you must stick to
their [commit message convention](https://github.com/semantic-release/semantic-release#commit-message-format) to use it.
This workflow utilizes [semantic-release](https://github.com/semantic-release/semantic-release) to
create a package release. Note that you must stick to
their [commit message convention](https://github.com/semantic-release/semantic-release#commit-message-format)
to use it.

You can provide a `release.config.js` file in your repository to create a custom release that uses the following
semantic-release plugins:
You can provide a `release.config.js` file in your repository to create a custom release that uses
the following semantic-release plugins:

- [git](https://github.com/semantic-release/git)
- [npm](https://github.com/semantic-release/npm)
- [exec](https://github.com/semantic-release/exec)

Otherwise, the workflow will create the release with a [standard set of configurations](../templates/automatic-release/release.config.js), updating the version in the
following files:
Otherwise, the workflow will create the release with
a [standard set of configurations](../templates/automatic-release/release.config.js), updating the
version in the following files:

- `CHANGELOG.md`
- `composer.json`
- `package-lock.json`
- `package.json`
- `style.css` or the main plugin file (automatically discovered by the workflow)

By default, every push to the `main` and `next` branches will release a stable version, and every push to the `alpha`
and `beta` branches will create a pre-release version.
If you want to use a different configuration, please provide your custom `release.config.js` file.
By default, every push to the `main` and `next` branches will release a stable version, and every
push to the `alpha` and `beta` branches will create a pre-release version. If you want to use a
different configuration, please provide your custom `release.config.js` file.

**Simplest possible example:**

Expand Down
Loading

0 comments on commit 04d6ff0

Please sign in to comment.