-
Notifications
You must be signed in to change notification settings - Fork 2
124 lines (105 loc) · 4.76 KB
/
Copy pathcd.yml
File metadata and controls
124 lines (105 loc) · 4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: CI/CD pipeline
on:
pull_request:
branches:
- '**'
push:
branches:
- 'main'
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
env:
# Change these values depending on project.
ps-module-name: saferpayofficial
project-workspace-dir: ${{ github.workspace }}/../workspace
strategy:
matrix:
PS: [ 1.7.8-7.4 ]
testsuite: [ lint, phpstan ]
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.0
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
- name: Set Swap Space
uses: Invertus/set-swap-space@master
with:
swap-size-gb: 10
- name: Set up workspace
shell: bash
run: |
eval `ssh-agent -s`
ssh-add - <<< "${{ secrets.PS_MODULE_WORKSPACE_SAFERPAY_PRIVATE_KEY }}"
git clone git@github.com:Invertus/ps-module-workspace.git ${{ env.project-workspace-dir }}
cd ${{ env.project-workspace-dir }}
sed 's/PROJECT_NAME=.*/PROJECT_NAME=${{ env.ps-module-name }}/g' < .env.dist |
sed 's/PS_VERSION_TAG=.*/PS_VERSION_TAG=${{ matrix.PS }}/g' > .env
make create-modules-dir
cp -R ${{ github.workspace }} ${{ env.project-workspace-dir }}/prestashop/${{ matrix.PS }}/modules/${{ env.ps-module-name }}
- name: Run PrestaShop
run: |
(cd ${{ env.project-workspace-dir }} && docker compose up -d)
- name: Healthcheck
run: |
timeout 120s sh -c 'until docker ps | grep ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} | grep -q "(healthy)"; do echo "Waiting for container to be healthy..."; sleep 1; done'
- name: Cache composer folder
uses: actions/cache@v3
with:
path: ${{ env.project-workspace-dir }}/prestashop/${{ matrix.PS }}/modules/${{ env.ps-module-name }}/vendor
key: ${{ github.sha }}
- name: Install git
run: |
docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "apt update && apt install -y git"
- name: Remove old module
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html/modules && rm -rf ${{ env.ps-module-name }}"
- name: Install module
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html/modules && git clone https://github.com/Invertus/${{ env.ps-module-name }}"
- name: Switch to the correct branch
run: |
docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html/modules/${{ env.ps-module-name }} && git fetch origin && git checkout ${{ github.head_ref || github.ref_name }}"
- name: Install composer dependencies
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html/modules/${{ env.ps-module-name }} && composer install"
- name: PHP version
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "php -v"
- name: Run ${{ matrix.testsuite }} tests
run: docker exec -i ${{ env.ps-module-name }}-ps-prestashop-${{ matrix.PS }} bash -c "cd /var/www/html/modules/${{ env.ps-module-name }} && make ci-${{ matrix.testsuite }} ps_version_tag=${{ matrix.PS }}"
prepare-zip:
name: Prepare module ZIP artifact
runs-on: ubuntu-latest
needs: [ test ]
env:
MODULE_NAME: saferpayofficial
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.12.0
with:
access_token: ${{ github.token }}
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build module ZIP
run: |
composer dump-autoload --no-dev --optimize --classmap-authoritative
cp .github/.htaccess vendor/.htaccess
rm -rf .git .github tests .php-cs-fixer.php Makefile cypress* docker-compose*.yml package.json package-lock.json .docker vendor-bin vendor/hambug update_installed_json.php
mkdir ${{ env.MODULE_NAME }}
rsync -Rr ./ ./${{ env.MODULE_NAME }}
chmod -R 777 ${{ env.MODULE_NAME }}/var/cache
shopt -s extglob
rm -r !(${{ env.MODULE_NAME }})
find . -maxdepth 1 -type f -exec rm "{}" \;
cd ${{ env.MODULE_NAME }} && rm -rf ${{ env.MODULE_NAME }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
name: ${{ env.MODULE_NAME }}
path: ./