Skip to content

Commit

Permalink
fix the action
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Dec 16, 2023
1 parent 488a040 commit 7c9f652
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 4 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

jobs:
integration-tests-remote:
name: Integration testing for base repository
runs-on: ${{ matrix.image }}

strategy:
fail-fast: false
matrix:
image: [ubuntu-20.04]
suittest: ["normal", "with_plugin"]
php: ["8.1", "8.2", "8.3"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Clone ShockedPlot7560/PmmpUnit repository
uses: actions/checkout@v4
with:
repository: ShockedPlot7560/PmmpUnit
path: PmmpUnit
fetch-depth: 1

- name: Test action
uses: ./
with:
php-version: ${{ matrix.php }}
suite-test: ${{ matrix.suittest }}
tests-path: PmmpUnit/tests/pmmpunit

integration-tests-custom:
name: Integration testing for specific action
runs-on: ${{ matrix.image }}

strategy:
fail-fast: false
matrix:
image: [ubuntu-20.04]
suittest: ["no-test"]
php: ["8.1", "8.2", "8.3"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Clone ShockedPlot7560/PmmpUnit repository
uses: actions/checkout@v4
with:
repository: ShockedPlot7560/PmmpUnit
path: PmmpUnit
fetch-depth: 1

- name: Test action
uses: ./
with:
php-version: ${{ matrix.php }}
suite-test: ${{ matrix.suittest }}
tests-path: tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin
14 changes: 12 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
name: 'PmmpUnit Tests'
description: 'Run PmmpUnit Tests'

inputs:
suite-test:
description: "Suite test to run"
Expand All @@ -16,21 +17,30 @@ inputs:
description: 'Path to env file'
required: false
default: '.env'
timeout:
description: 'Timeout for tests'
required: false
default: '10'

outputs:
failed-tests:
description: 'Number of failed tests'

runs:
using: 'composite'
steps:
- name: 'Prepare environment'
shell: bash
id: "prepare"
run: "${{github.action_path}}/prepare.sh ${{ inputs.php-version }} ${{ inputs.tests-path }} ${{ inputs.suite-test }} ${{ inputs.env-file }}"

- name: 'Run tests'
shell: bash
timeout-minutes: ${{ inputs.timeout }}
id: "run"
run: "${{github.action_path}}/run.sh ${{ outputs.prepare.pocketmine-name }}"
run: "${{github.action_path}}/run.sh ${{ steps.prepare.outputs.pocketmine_name }}"

- name: 'Collect results'
shell: bash
id: "finish"
run: "${{github.action_path}}/exitpoint.sh ${{ outputs.prepare.pocketmine-name }}"
run: "${{github.action_path}}/exitpoint.sh ${{ steps.prepare.outputs.pocketmine_name }}"
10 changes: 8 additions & 2 deletions prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@ ENV_FILE=$4
DOCKER_IMAGE="ghcr.io/shockedplot7560/pmmpunit/tests-runner-php${PHP_VERSION}:latest"
NETWORK_NAME=$CONTAINER_PREFIX-network
POCKETMINE_NAME=$CONTAINER_PREFIX-pocketmine
PWD=$(pwd)

docker network create $NETWORK_NAME || true
docker rm $POCKETMINE_NAME || true
docker rm -f $POCKETMINE_NAME || true

docker pull $DOCKER_IMAGE
docker create --name $POCKETMINE_NAME \
--network $NETWORK_NAME \
--env-file=$ENV_FILE \
$DOCKER_IMAGE

chown -R 1000:1000 $TESTS_PATH
docker cp $TESTS_PATH/shared/data $POCKETMINE_NAME:/data/plugin_data
docker cp $TESTS_PATH/suitetest/$SUITE_TEST/config $POCKETMINE_NAME:/data/plugin_data
docker cp $TESTS_PATH/suitetest/$SUITE_TEST/plugins $POCKETMINE_NAME:/
mkdir /tmp/PmmpUnit
chown -R 1000:1000 /tmp/PmmpUnit
docker cp /tmp/PmmpUnit $POCKETMINE_NAME:/data/plugin_data # create folder for PmmpUnit
docker cp $TESTS_PATH/suitetest/$SUITE_TEST/tests/. $POCKETMINE_NAME:/data/plugin_data/PmmpUnit/tests

echo "pocketmine-name=$POCKETMINE_NAME" >> $GITHUB_OUTPUT
echo "pocketmine_name=$POCKETMINE_NAME" >> $GITHUB_OUTPUT

0 comments on commit 7c9f652

Please sign in to comment.