Skip to content

Use GitHub Actions

Use GitHub Actions #1

Workflow file for this run

name: movabletype/mt-plugin-shared-preview
on:
push:
branches:
- "**/*"
pull_request:
schedule:
- cron: '30 0 * * 0' # Sunday Only
concurrency:
# # This item has no matching transformer
# maximum_number_of_builds: 0
group: "${{ github.ref }}"
cancel-in-progress: true
env:
MT_TEST_IGNORE_FIXTURE: '0'
jobs:
shared-preview:
env:
TEST_IMAGE_NAME: fedora39 # Perl 5.38 / PHP 8.2 / MySQL 8.0
if: ${{ always() }}
runs-on: ubuntu-latest
strategy:
matrix:
test:
- "plugins/SharedPreview/t"
steps:
- name: checkout
uses: actions/checkout@v4.1.0
- name: docker login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: core checkout
run: |
git clone -b develop --depth 1 https://github.com/movabletype/movabletype.git movabletype
cp -r movabletype/* .
cp movabletype/.perlcriticrc .
- name: test
run: docker run -t -v $PWD:/mt -w /mt ghcr.io/movabletype/movabletype/test:$TEST_IMAGE_NAME bash -c "prove -lr -j4 -PMySQLPool=MT::Test::Env -It/lib ${{ matrix.test }}"
core:
needs: [shared-preview]
if: >-
${{
github.event_name == 'schedule'
|| (github.ref_name == 'master')
}}
runs-on: ubuntu-latest
env:
TEST_IMAGE_NAME: cloud7
strategy:
matrix:
test:
- "t/*.t"
- "t/mt7/[^td]*"
- "t/mt7/d*"
- "t/mt7/t*"
- "t/admin_theme_id/ t/app/ t/class/ t/cms/ t/model/ t/mt_object/ t/object_driver/ t/task/ t/template/ t/tools t/util t/upgrade"
- "t/cms_permission/"
- "t/data_api/"
- "t/tag/"
- "plugins/*/t"
- php
steps:
- name: checkout
uses: actions/checkout@v4.1.0
- name: docker login
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: core checkout
run: |
git clone -b develop --depth 1 https://github.com/movabletype/movabletype.git movabletype
cp -r movabletype/* .
cp movabletype/.perlcriticrc .
- name: test
if: ${{ matrix.test != 'php' }}
run: docker run -t -v $PWD:/mt -w /mt ghcr.io/movabletype/movabletype/test:$TEST_IMAGE_NAME bash -c "prove -lr -j4 -PMySQLPool=MT::Test::Env -It/lib ${{ matrix.test }}"
- name: test php
if: ${{ matrix.test == 'php' }}
run: docker run -t -v $PWD:/mt -w /mt ghcr.io/movabletype/movabletype/test:$TEST_IMAGE_NAME bash -c "phpunit && make test-php-lint"
notify_slack:
runs-on: ubuntu-latest
needs:
- shared-preview
- core
if: ${{ always() }}
steps:
- name: Install jq
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Filters if the "needs" context has "failure"
run: |
HAS_FAILURE=$(echo '${{ toJSON(needs) }}' | jq '[.[] | select(.result == "failure") | .result] | join(",")' | sed -e 's/"//g')
echo "HAS_FAILURE=${HAS_FAILURE}" >> "$GITHUB_ENV"
- name: SLACK_COLOR is danger
if: ${{ env.HAS_FAILURE }}
run: |
echo "SLACK_COLOR=danger" >> "$GITHUB_ENV"
- name: SLACK_COLOR is good
if: ${{ ! env.HAS_FAILURE }}
run: |
echo "SLACK_COLOR=good" >> "$GITHUB_ENV"
- uses: rtCamp/action-slack-notify@v2.2.1
env:
SLACK_WEBHOOK: "${{ secrets.SLACK_WEBHOOK }}"
SLACK_USERNAME: "GitHub Actions ${{ github.repository }}"
SLACK_TITLE: 'Workflow #${{ github.run_number }}'
SLACK_ICON: https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png
SLACK_COLOR: "${{ env.SLACK_COLOR }}"