Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 6 additions & 190 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,195 +7,11 @@ on:
pull_request:
branches:
- '1.x'

env:
LOCALGOV_DRUPAL_PROJECT: localgovdrupal/localgov_blogs
LOCALGOV_DRUPAL_PROJECT_PATH: web/modules/contrib/localgov_blogs
workflow_dispatch:

jobs:

build:
name: Install LocalGov Drupal
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'
- '8.2'

steps:

- name: Save git branch and git repo names to env if this is not a pull request
if: github.event_name != 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV

- name: Save git branch and git repo names to env if this is a pull request
if: github.event_name == 'pull_request'
run: |
echo "GIT_BASE=${GITHUB_BASE_REF}" >> $GITHUB_ENV
echo "GIT_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV

- name: Set composer branch reference for version branches
if: endsWith(github.ref, '.x')
run: echo "COMPOSER_REF=${GIT_BRANCH}-dev" >> $GITHUB_ENV

- name: Set composer branch reference for non-version branches
if: endsWith(github.ref, '.x') == false
run: echo "COMPOSER_REF=dev-${GIT_BRANCH}" >> $GITHUB_ENV

- name: Get the latest tagged release for branch version
run: |
LATEST_RELEASE=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/${GITHUB_REPOSITORY}/git/matching-refs/tags/${GIT_BASE%'.x'} | grep -Po '(?<=refs/tags/)[^"]+' | tail -1)
if [ -z $LATEST_RELEASE ]; then LATEST_RELEASE=1; fi
echo "LATEST_RELEASE=${LATEST_RELEASE}" >> $GITHUB_ENV

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Clone drupal_container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: php${{ matrix.php-version }}

- name: Create LocalGov Drupal project
run: |
composer create-project --stability dev --no-install localgovdrupal/localgov-project ./html "${{ matrix.localgov-version }}"
composer --working-dir=./html require --no-install localgovdrupal/localgov:${{ matrix.localgov-version }}-dev
composer --working-dir=./html require --no-install drupal/core-recommended:${{ matrix.drupal-version }} drupal/core-composer-scaffold:${{ matrix.drupal-version }} drupal/core-project-message:${{ matrix.drupal-version }} drupal/core-dev:${{ matrix.drupal-version }}
composer --working-dir=./html install

- name: Obtain the test target from the repo that triggered this workflow
run: |
composer --working-dir=html config repositories.1 vcs git@github.com:${LOCALGOV_DRUPAL_PROJECT}.git
composer global config github-oauth.github.com ${{ github.token }}
composer --working-dir=./html require --with-all-dependencies ${LOCALGOV_DRUPAL_PROJECT}:"${COMPOSER_REF} as ${LATEST_RELEASE}"

phpcs:
name: Coding standards checks
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'
- '8.2'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Run coding standards checks
run: |
cd html
./bin/phpcs -p ${LOCALGOV_DRUPAL_PROJECT_PATH}

phpstan:
name: Deprecated code checks
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'
- '8.2'

steps:

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}

- name: Run deprecated code checks
run: |
cd html
./bin/phpstan analyse -c ./phpstan.neon ${LOCALGOV_DRUPAL_PROJECT_PATH}
phpunit:
name: PHPUnit tests
needs: build
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
localgov-version:
- '3.x'
drupal-version:
- '~10.0'
php-version:
- '8.1'
- '8.2'

steps:

- name: Clone Drupal container
uses: actions/checkout@v2
with:
repository: localgovdrupal/drupal-container
ref: php${{ matrix.php-version }}

- name: Cached workspace
uses: actions/cache@v2
with:
path: ./html
key: localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-${{ github.run_id }}-${{ secrets.CACHE_VERSION }}
restore-keys: |
localgov-build-${{ matrix.localgov-version }}-${{ matrix.drupal-version }}-${{ matrix.php-version }}-

- name: Start Docker environment
run: docker-compose -f docker-compose.yml up -d

- name: Run PHPUnit tests
run: |
mkdir -p ./html/web/sites/simpletest && chmod 777 ./html/web/sites/simpletest
sed -i "s#http://localgov.lndo.site#http://drupal#" ./html/phpunit.xml.dist
docker exec -t drupal bash -c 'chown docker:docker -R /var/www/html'
docker exec -u docker -t drupal bash -c "cd /var/www/html && ./bin/paratest --processes=4 /var/www/html/${{ env.LOCALGOV_DRUPAL_PROJECT_PATH }}"
tests:
uses: localgovdrupal/localgov_shared_workflows/.github/workflows/test-module.yml@1.x
with:
project: 'localgovdrupal/localgov_blogs'
project_path: 'web/modules/contrib/localgov_blogs'
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,31 @@

# LocalGov Drupal Blogs

Provides blog channel and blog post content types with related views for LocalGov Drupal.
This module provides blog channel and blog post content types with related views for the LocalGov Drupal distribution.

## Content types

The content types this module provides are:
- Blog channel
- Blog post

## Other features

The module includes an optional Previous / Next Navigation block - called Blog Previous Next block - which can be added to any region using block layout
Normally added to the `Content bottom` region and restricted to just `Blog post` content types

## Installing

You can install this module with the following composer command.

```
composer require localgovdrupal/localgov_blogs:^1.0.0
```

## Issues

If you run into issues using this module, please report them at https://github.com/localgovdrupal/localgov_blogss/issues

## Maintainers

TBC
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
langcode: en
status: true
dependencies:
config:
- field.storage.node.localgov_blog_posts
- node.type.localgov_blog_channel
- node.type.localgov_blog_post
id: node.localgov_blog_channel.localgov_blog_posts
field_name: localgov_blog_posts
entity_type: node
bundle: localgov_blog_channel
label: localgov_blog_posts
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:node'
handler_settings:
target_bundles:
localgov_blog_post: localgov_blog_post
sort:
field: _none
direction: ASC
auto_create: false
auto_create_bundle: ''
field_type: entity_reference
18 changes: 18 additions & 0 deletions config/install/field.storage.node.localgov_blog_posts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
langcode: en
status: true
dependencies:
module:
- node
id: node.localgov_blog_posts
field_name: localgov_blog_posts
entity_type: node
type: entity_reference
settings:
target_type: node
module: core
locked: false
cardinality: -1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
langcode: en
status: true
dependencies:
module:
- localgov_blogs
theme:
- localgov_base
id: localgov_blogs_prev_next_block_base
theme: localgov_base
region: content_bottom
weight: -6
provider: null
plugin: localgov_blogs_prev_next_block
settings:
id: localgov_blogs_prev_next_block
label: 'Blogs prev next block'
provider: localgov_blogs
label_display: '0'
visibility: { }
7 changes: 7 additions & 0 deletions config/schema/localgov_blogs_prev_next_block_base.schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
block.settings.localgov_blogs_prev_next_block:
type: block_settings
label: 'Previous Next button block settings'
mapping:
show_title:
type: boolean
label: 'Show title'
10 changes: 10 additions & 0 deletions localgov_blogs.install
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
use Drupal\Core\Config\Config;
use Symfony\Component\Yaml\Yaml;

/**
* Implements hook_install().
*/
function localgov_blogs_install($is_syncing) {
// Configure scheduled transitions if enabled.
if (!$is_syncing && \Drupal::moduleHandler()->moduleExists('scheduled_transitions')) {
localgov_blogs_configure_scheduled_transitions();
}
}

/**
* Add the new view for blog authors.
*/
Expand Down
Loading
Loading