25
25
26
26
# Step 3: Checkout the branch associated with the PR
27
27
- name : Checkout PR branch ${{ steps.comment-branch.outputs.head_ref }}
28
- uses : actions/checkout@v4
28
+ uses : actions/checkout@v3
29
29
with :
30
30
ref : ${{ steps.comment-branch.outputs.head_sha }}
31
31
@@ -55,75 +55,60 @@ jobs:
55
55
echo "Comment does not match the expected format."
56
56
exit 1
57
57
fi
58
-
59
- - name : Login to GitHub Container Registry
60
- uses : docker/login-action@v2
58
+ - name : Configure Build X
59
+ uses : docker/setup-buildx-action@v1
60
+ - name : Build
61
+ uses : docker/build-push-action@v2
61
62
with :
62
- registry : ghcr.io
63
- username : ${{ github.actor }}
64
- password : ${{ secrets.GITHUB_TOKEN }}
65
-
63
+ context : .
64
+ file : Dockerfile.ci
65
+ cache-from : type=gha
66
+ cache-to : type=gha,mode=max
67
+ tags : cms-web
68
+ build-args : GIT_COMMIT=${{ github.sha }}
69
+ push : false
70
+ load : true
66
71
- name : Pull
67
72
run : |
68
73
docker pull mysql:8
69
74
docker pull ghcr.io/xibosignage/xibo-xmr:latest
70
- docker pull ghcr.io/xibosignage/xibo-cms:test-${{ github.event.issue.number }}
71
-
72
75
- name : Run
73
76
run : |
74
77
docker run --name cms-db -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_DATABASE=cms -e MYSQL_USER=cms -e MYSQL_PASSWORD=jenkins -d mysql:8
75
78
docker run --name cms-xmr -d ghcr.io/xibosignage/xibo-xmr:latest
76
- docker run --name cms-web -e MYSQL_HOST=cms-db -e MYSQL_USER=cms -e MYSQL_PASSWORD=jenkins -e CMS_DEV_MODE=true -e XMR_HOST=cms-xmr -e CMS_USAGE_REPORT=false -e INSTALL_TYPE=ci -e MYSQL_BACKUP_ENABLED=false --link cms-db --link cms-xmr -d ghcr.io/xibosignage/xibo-cms:test-${{ github.event.issue.number }}
77
-
79
+ docker run --name cms-web -e MYSQL_USER=cms -e MYSQL_PASSWORD=jenkins -e XIBO_DEV_MODE=true -e XMR_HOST=cms-xmr --link cms-db:db --link cms-xmr:50001 -d cms-web
78
80
- name : Wait for CMS
79
81
run : |
80
82
docker exec -t cms-web /bin/bash -c "/usr/local/bin/wait-for-command.sh -q -t 300 -c \"nc -z localhost 80\""
81
83
docker cp cms-web:/var/www/cms/web/settings.php web/settings.php
82
84
docker exec -t cms-web /bin/bash -c "chown -R www-data.www-data /var/www/cms"
83
85
docker exec --user www-data -t cms-web /bin/bash -c "cd /var/www/cms; /usr/bin/php bin/run.php 1"
84
86
sleep 5
85
-
86
87
- name : Seed Database
87
88
run : |
88
89
docker exec cms-db mysql -ucms -pjenkins cms -e "UPDATE setting SET value=\"6v4RduQhaw5Q\" WHERE setting = \"SERVER_KEY\" "
89
90
docker exec cms-db mysql -ucms -pjenkins cms -e "INSERT INTO task (name, class, status, isActive, configFile, options, schedule) VALUES ('Seed Database', '\\\\Xibo\\\\XTR\\\\SeedDatabaseTask', 2, 1, '/tasks/seed-database.task', '{}', '* * * * * *')"
90
91
docker exec --user www-data -t cms-web /bin/bash -c "cd /var/www/cms; /usr/bin/php bin/run.php \"Seed Database\""
91
92
sleep 5
92
-
93
93
- name : Run PHP Unit
94
94
run : |
95
95
docker exec --user www-data -t cms-web /bin/bash -c "cd /var/www/cms; php vendor/bin/phpunit --log-junit results.xml"
96
-
97
96
- name : Run Cypress
98
97
id : cypress
99
98
run : |
100
99
docker exec cms-db mysql -ucms -pjenkins cms -e "INSERT INTO oauth_clients (id, secret, name, userId, authCode, clientCredentials) VALUES ('MrGPc7e3IL1hA6w13l7Ru5giygxmNiafGNhFv89d', 'Pk6DdDgu2HzSoepcMHRabY60lDEvQ9ucTejYvc5dOgNVSNaOJirCUM83oAzlwe0KBiGR2Nhi6ltclyNC1rmcq0CiJZXzE42KfeatQ4j9npr6nMIQAzMal8O8RiYrIoono306CfyvSSJRfVfKExIjj0ZyE4TUrtPezJbKmvkVDzh8aj3kbanDKatirhwpfqfVdfgsqVNjzIM9ZgKHnbrTX7nNULL3BtxxNGgDMuCuvKiJFrLSyIIz1F4SNrHwHz', 'cypress', 1, 0, 1)"
101
100
docker exec cms-db mysql -ucms -pjenkins cms -e "INSERT INTO oauth_client_scopes (clientId, scopeId) VALUES ('MrGPc7e3IL1hA6w13l7Ru5giygxmNiafGNhFv89d', 'all') ON DUPLICATE KEY UPDATE scopeId = scopeId"
102
101
if [[ "$test_all" == true ]]; then
103
- docker run --ipc=host --name cms-cypress --link=cms-web:web -v $(pwd)/cypress.config.js:/app/cypress.config.js -v $(pwd)/cypress:/app/cypress ghcr.io/xibosignage/xibo-cms:cypress npx testmo automation:resources:add-field --name git --type string --value ${GITHUB_SHA:0:7} --resources resources.json
102
+ docker run --ipc=host --name cms-cypress --link=cms-web:web -v $(pwd)/cypress.config.js:/app/cypress.config.js -v $(pwd)/cypress:/app/cypress ghcr.io/xibosignage/xibo-cms:cypress bash -c "CYPRESS_baseUrl=http://web /app/node_modules/.bin/cypress run --config screenshotsFolder=/app/cypress/results,video=false --reporter junit --reporter-options 'mochaFile=/app/cypress/results/results_cypress_[hash].xml,toConsole=true' && chown -R 1001:1001 /app/cypress/results && exit \${PIPESTATUS[0]};"
104
103
else
105
- docker run --ipc=host --name cms-cypress --link=cms-web:web -v $(pwd)/cypress.config.js:/app/cypress.config.js \
106
- -v $(pwd)/cypress:/app/cypress ghcr.io/xibosignage/xibo-cms:cypress \
107
- npx testmo automation:run:submit \
108
- --instance "$TESTMO_URL" \
109
- --project-id 1 \
110
- --name "Cypress Tests" \
111
- --source "github-action" \
112
- --resources resources.json \
113
- --results cypress/results/*.xml \
114
- -- bash -c "CYPRESS_baseUrl=http://web /app/node_modules/.bin/cypress run --config screenshotsFolder=/app/cypress/results,video=false --spec \"$spec_content\" --reporter junit --reporter-options 'mochaFile=/app/cypress/results/results_cypress_[hash].xml,toConsole=true' && chown -R 1001:1001 /app/cypress/results && exit \${PIPESTATUS[0]};"
104
+ docker run --ipc=host --name cms-cypress --link=cms-web:web -v $(pwd)/cypress.config.js:/app/cypress.config.js -v $(pwd)/cypress:/app/cypress ghcr.io/xibosignage/xibo-cms:cypress bash -c "CYPRESS_baseUrl=http://web /app/node_modules/.bin/cypress run --config screenshotsFolder=/app/cypress/results,video=false --spec \"$spec_content\" --reporter junit --reporter-options 'mochaFile=/app/cypress/results/results_cypress_[hash].xml,toConsole=true' && chown -R 1001:1001 /app/cypress/results && exit \${PIPESTATUS[0]};"
115
105
fi
116
106
continue-on-error : true
117
- env :
118
- TESTMO_URL : ${{ secrets.TESTMO_URL }}
119
- TESTMO_TOKEN : ${{ secrets.TESTMO_TOKEN }}
120
-
121
107
- name : Save Cypress test results as an artifact
122
108
uses : actions/upload-artifact@v3
123
109
with :
124
110
name : cypress-test-results
125
111
path : cypress/results
126
-
127
112
- name : Check Cypress exit code
128
113
run : |
129
114
if [[ ${{ steps.cypress.outcome }} == 'success' ]]; then
@@ -132,14 +117,13 @@ jobs:
132
117
echo "Cypress tests failed with exit code ${{ steps.cypress.exitCode }}"
133
118
exit 1
134
119
fi
135
-
136
120
# Step 5: Add a comment to the PR with the workflow result
137
121
- name : Add workflow result as comment on PR
138
122
uses : actions/github-script@v6
139
123
if : always()
140
124
with :
141
125
script : |
142
- const name = '${{ github.workflow }}';
126
+ const name = '${{ github.workflow }}';
143
127
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
144
128
const success = '${{ job.status }}' === 'success';
145
129
const body = `${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\n${url}`;
@@ -159,3 +143,4 @@ jobs:
159
143
sha : ${{ steps.comment-branch.outputs.head_sha }}
160
144
token : ${{ secrets.GITHUB_TOKEN }}
161
145
status : ${{ job.status }}
146
+
0 commit comments