Skip to content

Commit 694929e

Browse files
authored
Merge pull request #4 from reload/tests
Add tests.
2 parents 23be29f + 96928e0 commit 694929e

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.github/workflows/tests.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: "Testing action-platformsh-url"
2+
3+
on: pull_request
4+
permissions: write-all
5+
6+
jobs:
7+
ok-test:
8+
name: "Testing on a branch that has an active, deployed environment"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- uses: ./
14+
with:
15+
PLATFORMSH_ID: ${{ secrets.TEST_PLATFORMSH_ID }}
16+
PLATFORMSH_KEY: ${{ secrets.TEST_PLATFORMSH_KEY }}
17+
ENVIRONMENT_NAME: main
18+
19+
fail-deploy-test:
20+
name: "Testing on a environment that has a failed deployment"
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
25+
- uses: ./
26+
id: inactive_url
27+
continue-on-error: true
28+
with:
29+
PLATFORMSH_ID: ${{ secrets.TEST_PLATFORMSH_ID }}
30+
PLATFORMSH_KEY: ${{ secrets.TEST_PLATFORMSH_KEY }}
31+
ENVIRONMENT_NAME: main
32+
DEPLOY_STATUS_PATH: '/sites/default/files/mock-deploy-status'
33+
34+
- name: Check for failure
35+
if: ${{ steps.inactive_url.outputs.url }}
36+
uses: actions/github-script@v3
37+
with:
38+
script: |
39+
core.setFailed('The test did not fail as expected.')
40+
41+
42+
missing-url-test:
43+
name: "Testing on a environment that that has no URL"
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v2
47+
48+
- uses: ./
49+
id: missing_url
50+
continue-on-error: true
51+
with:
52+
PLATFORMSH_ID: ${{ secrets.TEST_PLATFORMSH_ID }}
53+
PLATFORMSH_KEY: ${{ secrets.TEST_PLATFORMSH_KEY }}
54+
ENVIRONMENT_NAME: main
55+
DEPLOY_STATUS_PATH: '/sites/default/files/xxx-deploy-status'
56+
57+
- name: Check for failure
58+
if: ${{ steps.missing_url.outputs.url }}
59+
uses: actions/github-script@v3
60+
with:
61+
script: |
62+
core.setFailed('The test did not fail as expected.')

action.yml

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ inputs:
2727
required: false
2828
type: string
2929

30+
DEPLOY_WAIT_TIME:
31+
description: "How long should we maximum wait for the deploy to work? If the branch doesnt exist in the PlatformSH GIT Remote, this is how long the action will take. Actually inactive environments get detected instantly. Default: 500 seconds."
32+
default: 500
33+
required: false
34+
type: integer
3035

3136
outputs:
3237
status:
@@ -40,6 +45,9 @@ runs:
4045
with:
4146
PLATFORMSH_ID: ${{ inputs.PLATFORMSH_ID }}
4247
PLATFORMSH_KEY: ${{ inputs.PLATFORMSH_KEY }}
48+
ENVIRONMENT_NAME: ${{ inputs.ENVIRONMENT_NAME }}
49+
DEPLOY_WAIT_TIME: ${{ inputs.DEPLOY_WAIT_TIME }}
50+
4351
- name: Check latest deploy status
4452
shell: bash
4553
run: |
@@ -69,4 +77,6 @@ runs:
6977
exit 2; \
7078
fi
7179
80+
echo "::set-output name=url::$(echo $DEPLOY_STATUS_URL)"
81+
7282
echo "PlatformSH successfully deployed your PR."

0 commit comments

Comments
 (0)