Skip to content

Commit 90ca918

Browse files
committed
ci: add test workflow
1 parent 837dcc3 commit 90ca918

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test-devcontainer:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
magento_version: ["2.4.6", "2.4.7", "2.4.8"]
16+
17+
name: Magento ${{ matrix.magento_version }}
18+
19+
steps:
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Install devcontainer CLI
24+
run: npm install -g @devcontainers/cli
25+
26+
- name: Create Magento project
27+
run: |
28+
composer create-project --no-install \
29+
--repository-url=https://mirror.mage-os.org/ \
30+
magento/project-community-edition=${{ matrix.magento_version }} test-project
31+
32+
- name: Checkout devcontainer
33+
uses: actions/checkout@v4
34+
with:
35+
path: test-project/.devcontainer/magento2-devcontainer
36+
37+
- name: Initialize devcontainer configuration
38+
working-directory: test-project
39+
run: |
40+
# Run init.sh - it will auto-detect the Magento version from composer.json
41+
# Just need to provide the devcontainer name (empty = default)
42+
printf '\n' | .devcontainer/magento2-devcontainer/bin/init.sh
43+
44+
# Show the generated config
45+
echo "=== devcontainer.json ==="
46+
cat .devcontainer/devcontainer.json
47+
48+
- name: Build and start devcontainer
49+
working-directory: test-project
50+
run: |
51+
devcontainer up --workspace-folder .
52+
53+
- name: Verify services are running
54+
working-directory: test-project
55+
run: |
56+
echo "Waiting for services to be ready..."
57+
sleep 15
58+
59+
echo "=== Checking PHP ==="
60+
devcontainer exec --workspace-folder . php -v
61+
62+
echo "=== Checking database ==="
63+
devcontainer exec --workspace-folder . \
64+
bash -c 'mysql -h db -umagento -pmagento -e "SELECT 1" magento'
65+
66+
echo "=== Checking OpenSearch ==="
67+
devcontainer exec --workspace-folder . \
68+
bash -c 'curl -s http://opensearch:9200/_cluster/health'
69+
70+
echo "=== Checking RabbitMQ ==="
71+
devcontainer exec --workspace-folder . \
72+
bash -c 'curl -s -u magento:magento http://rabbitmq:15672/api/overview | head -c 200'
73+
74+
echo ""
75+
echo "=== Checking Redis ==="
76+
devcontainer exec --workspace-folder . \
77+
bash -c 'redis-cli -h redis ping'
78+
79+
- name: Install Magento dependencies
80+
working-directory: test-project
81+
run: |
82+
devcontainer exec --workspace-folder . composer install
83+
84+
- name: Run setup-install.sh
85+
working-directory: test-project
86+
run: |
87+
echo "=== Generated setup:install command ==="
88+
devcontainer exec --workspace-folder . \
89+
bash -c '.devcontainer/magento2-devcontainer/bin/setup-install.sh'
90+
91+
echo ""
92+
echo "=== Running Magento setup:install ==="
93+
devcontainer exec --workspace-folder . \
94+
bash -c '.devcontainer/magento2-devcontainer/bin/setup-install.sh | bash'
95+
96+
- name: Verify Magento installation
97+
working-directory: test-project
98+
run: |
99+
echo "=== Checking Magento version ==="
100+
devcontainer exec --workspace-folder . bin/magento --version
101+
102+
echo "=== Checking Magento status ==="
103+
devcontainer exec --workspace-folder . bin/magento setup:status
104+
105+
- name: Show container status
106+
if: always()
107+
working-directory: test-project
108+
run: |
109+
docker ps -a
110+
111+
- name: Show logs on failure
112+
if: failure()
113+
working-directory: test-project
114+
run: |
115+
echo "=== Docker Compose Logs ==="
116+
docker compose \
117+
-f .devcontainer/docker-compose.yml \
118+
-f .devcontainer/magento2-devcontainer/compose/${{ matrix.magento_version }}/docker-compose.yml \
119+
-f .devcontainer/magento2-devcontainer/docker-compose.shared.yml \
120+
-f .devcontainer/magento2-devcontainer/docker-compose.local.yml \
121+
logs --tail=100 || true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.env
22
.*/
3+
!.github
34
docker-compose.local.yml

0 commit comments

Comments
 (0)