Skip to content

Commit

Permalink
Merge branch 'develop' into release/1.2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppekroghitk authored Sep 17, 2024
2 parents 68ab824 + 2f0893c commit 4393d63
Show file tree
Hide file tree
Showing 17 changed files with 202 additions and 1,921 deletions.
104 changes: 35 additions & 69 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,92 +9,58 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Git fetch
run: git fetch

- name: Check that changelog has been updated.
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0

markdown-coding-standards:
name: Markdown coding standards
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Coding standards
run: |
docker run --rm --volume "$PWD":/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
assets-coding-standards:
name: Assets coding standards
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Coding standards
run: |
docker run --volume ${PWD}:/app --rm node:20 yarn --cwd /app install
docker run --volume ${PWD}:/app --rm node:20 yarn --cwd /app prettier src --check
audit:
name: audit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: npm audit
run: |
npm install
npm audit
php-coding-standards:
name: PHP coding standards
documentation:
runs-on: ubuntu-latest
env:
# https://getcomposer.org/doc/03-cli.md#composer-auth
COMPOSER_AUTH: |
{
"github-oauth": {
"github.com": "${{ github.TOKEN }}"
}
}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Coding standards
run: |
docker compose run --rm --env COMPOSER_AUTH --user root php composer install
docker compose run --rm php composer coding-standards-check
shellcheck:
runs-on: ubuntu-latest
name: Shellcheck
name: Documentation should be updated
if: github.event_name == 'pull_request'
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Shellcheck
run: |
docker run --rm --tty --volume "$(pwd):/app" peterdavehello/shellcheck shellcheck /app/bin/deploy
- name: Git fetch
run: git fetch

check-create-release:
- name: Check that documentation (Markdown files excluding changelog and pr-template) has been updated.
run: git diff --exit-code origin/${{ github.base_ref }} -- git ls-files '*.md' ':!:CHANGELOG.md' ':!:.github/' && exit 1 || exit 0

run-code-blocks-from-readme:
runs-on: ubuntu-latest
name: Test create release
strategy:
fail-fast: false
matrix:
blocks:
- development-install markdown-check
- development-install composer-normalize
- development-install check-coding-standards
- development-install shell-check
- development-install code-analysis
- development-install test-create-release
steps:
- name: Checkout
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0

# https://github.com/actions/setup-go
- uses: actions/setup-go@v5
with:
go-version: '1.23.0'

- name: Create test release
run: |
./bin/create-release dev-test
# https://github.com/mikkelricky/markdown-code-runner
# We need to run as root in GitHub Actions, hence the `--substitutions` hack!
- run: |
go run github.com/mikkelricky/markdown-code-runner@latest run \
--verbose --echo '👉 ' \
--substitutions '{"docker run ": "docker run --user root ", "docker compose run ": "docker compose run --user root "}' \
${{ matrix.blocks }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.2.7] - 2024-09-13

* [PR-28](https://github.com/ITK-Leantime/leantime-omnisearch/pull/29)
* Streamline with template repository

* [PR-27](https://github.com/ITK-Leantime/leantime-omnisearch/pull/27)
* Added compatability for Leantime 3.2

Expand Down
4 changes: 2 additions & 2 deletions Controllers/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public function get(): Response

/**
* post method
* @param array $params
* @return Response
* @param array<string, mixed> $params
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function post(array $params): RedirectResponse
{
Expand Down
68 changes: 50 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,68 @@ docker compose run --rm php npm install
docker compose run --rm php npm run dev
```

## Coding standards
Run composer install

Run prettier via the following command:
```shell name=development-install
docker run --interactive --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer install
```

```shell
docker compose build
docker compose run --rm php npm install
docker compose run --rm php npm run coding-standards-apply
### Composer normalize

```shell name=composer-normalize
docker run --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer normalize
```

```shell
docker run --rm --volume "$(pwd):/md" peterdavehello/markdownlint markdownlint --ignore LICENSE.md --ignore vendor/ --ignore node_modules/ '**/*.md' --fix
docker run --rm --volume "$(pwd):/md" peterdavehello/markdownlint markdownlint --ignore LICENSE.md --ignore vendor/ --ignore node_modules/ '**/*.md'
### Coding standards

#### Check and apply with phpcs

```shell name=check-coding-standards
docker run --interactive --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer coding-standards-check
```

```shell
docker run --rm --tty --volume "$(pwd):/app" peterdavehello/shellcheck shellcheck /app/bin/deploy
```shell name=apply-coding-standards
docker run --interactive --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer coding-standards-apply
```

#### Check and apply with prettier

```shell name=prettier-check
docker run --rm -v "$(pwd):/work" tmknom/prettier:latest --check assets
```

```shell name=coding-standards-php
docker compose build
docker compose run --rm php composer install
docker compose run --rm php composer coding-standards-apply
docker compose run --rm php composer coding-standards-check
```shell name=prettier-apply
docker run --rm -v "$(pwd):/work" tmknom/prettier:latest --write assets
```

#### Check and apply markdownlint

```shell name=markdown-check
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md'
```

```shell name=markdown-apply
docker run --rm --volume $PWD:/md peterdavehello/markdownlint markdownlint --ignore vendor --ignore LICENSE.md '**/*.md' --fix
```

#### Check with shellcheck

```shell name=shell-check
docker run --rm --volume "$PWD:/app" --workdir /app peterdavehello/shellcheck shellcheck bin/create-release
docker run --rm --volume "$PWD:/app" --workdir /app peterdavehello/shellcheck shellcheck bin/deploy
docker run --rm --volume "$PWD:/app" --workdir /app peterdavehello/shellcheck shellcheck bin/local.create-release
```

### Code analysis

```shell name=code-analysis
docker run --interactive --rm --volume ${PWD}:/app itkdev/php8.3-fpm:latest composer code-analysis
```

## Test release build

``` shell
docker compose build && docker compose run --rm php bash bin/create-release dev-test
```shell name=test-create-release
docker compose build && docker compose run --rm php bin/create-release dev-test
```

The create-release script replaces `@@VERSION@@` in
Expand Down
7 changes: 5 additions & 2 deletions Services/OmniSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
/**
* OmniSearch plugin.
*/
class OmniSearch
final class OmniSearch
{
private static $assets = [
/**
* @var array<string, string>
*/
private static array $assets = [
// source => target
__DIR__ . '/../dist/js/omniSearch.js' => APP_ROOT . '/public/dist/js/omniSearch.v%%VERSION%%.js',
];
Expand Down
1 change: 1 addition & 0 deletions Templates/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


<div class="maincontent">
{{-- the below results in a phpstan error I don't know how to fix, so this file is excluded from code analysis (in phpstan.dist.neon) --}}
<?php echo $tpl->displayNotification(); ?>
<div class="maincontentinner">
<h5 class="subtitle">Omnisearch Settings</h5>
Expand Down
File renamed without changes.
File renamed without changes.
43 changes: 26 additions & 17 deletions bin/create-release
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
#!/usr/bin/env bash
set -o errexit -o errtrace -o noclobber -o nounset -o pipefail

IFS=$'\n\t'

script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
project_dir=$(cd "$(dirname "$script_dir")" && pwd)
# shellcheck source=local.create-release
local_create_release="bin/local.create-release"
release_exclude_file="bin/release-exclude.txt"

if [[ ! -f "$local_create_release" ]]; then
(>&2 echo "Error: $local_create_release does not exist. See README.")
exit
fi
# shellcheck source=local.create-release
source $local_create_release

if [[ ! -f "$release_exclude_file" ]]; then
(>&2 echo "Error: $release_exclude_file does not exist. See README.")
exit
fi

tag=${1:-}
if [ -z "$tag" ]; then
Expand All @@ -15,30 +31,23 @@ cd "$project_dir"

# Configuration start

plugin_name=OmniSearch

plugin_name="$plugin_name"
# Edit release-exclude.txt to exclude files and folder from release package.

# Configuration end

git config --global --add safe.directory "$PWD"
if ! git diff --exit-code package.json; then
(>&2 echo; echo package.json is changed. Aborting.)
if ! git diff --exit-code composer.json; then
(>&2 echo; echo composer.json is changed. Aborting.)
exit 1
fi

# Make sure that `composer.json` has the correct version.
composer config version "${tag}"

name="leantime-plugin-${plugin_name}-${tag}.tar.gz"

git config --global --add safe.directory "$PWD"
if ! git diff --exit-code package.json; then
(>&2 echo; echo package.json is changed. Aborting.)
exit 1
fi
# Script defined in local.create-release to build project-specific assets
buildRelease

# Build release start
npm install --no-dev
npm run build
# Build release end

# Package release
Expand All @@ -49,15 +58,15 @@ mkdir -p "$target_dir"
rsync --verbose --archive --compress --filter=':- .gitignore' --exclude-from "$script_dir/release-exclude.txt" . "$target_dir"

# Replace %%VERSION%% with actual version in build
find ${target_dir} -type f -exec sed -i "s/%%VERSION%%/${tag}/g" {} \;
find "${target_dir}" -type f -exec sed -i "s/%%VERSION%%/${tag}/g" {} \;

# Strip any leading `dev-` from tag name in package name.
name="${plugin_name}-${tag#dev-}.tar.gz"
tar --create --file "$name" -C "$release_dir" $plugin_name
tar --create --file "$name" -C "$release_dir" "$plugin_name"
sha256sum "$name" >| checksum.txt

# Clean up
rm -fr $release_dir
rm -fr "$release_dir"

git checkout composer.json

Expand Down
12 changes: 10 additions & 2 deletions bin/deploy
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/usr/bin/env bash
set -o errexit -o errtrace -o noclobber -o nounset -o pipefail

plugin_repo_url=https://github.com/ITK-Leantime/leantime-omnisearch
plugin_name=OmniSearch
# shellcheck source=local.create-release
local_create_release="./local.create-release"

if [[ ! -f "$local_create_release" ]]; then
(>&2 echo "Error: $local_create_release does not exist. See README.")
exit
fi

# shellcheck source=local.create-release
source $local_create_release

script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
plugins_dir=$(cd "$(dirname "$script_dir")"/.. && pwd)
Expand Down
13 changes: 13 additions & 0 deletions bin/local.create-release
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -o errexit -o errtrace -o noclobber -o nounset -o pipefail

export plugin_name=OmniSearch
export plugin_repo_url=https://github.com/ITK-Leantime/leantime-omnisearch/

buildRelease() {
npm install --no-dev
npm run build
return
}

export -f buildRelease
3 changes: 2 additions & 1 deletion bin/release-exclude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
.editorconfig
.git*
bin/create-release
bin/local.create-release
bin/release-exclude.txt
checksum.txt
compose.yaml
composer.lock
package-lock.json
node_modules
package.json
src
assets
.prettierignore
.prettierrc
Dockerfile
Expand Down
Loading

0 comments on commit 4393d63

Please sign in to comment.