-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (124 loc) · 4.6 KB
/
ci.yml
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: CI
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
env:
NAME: ctfer
PASSWORD: ctfer
services:
chall-manager:
image: ctferio/chall-manager:grpchttp
ports:
- 8080:8080
env:
CI: true
credentials:
username: ${{ secrets.docker_username }}
password: ${{ secrets.docker_password }}
mariadb:
image: mariadb:10.7.8
ports:
- 3306:3306
env:
MYSQL_ROOT_PASSWORD: ctfer
ctfd:
image: ctfd/ctfd:3.7.3@sha256:90470e1fe0f93028ce6ac197b8942916ee157d4b5d33c8266c5bec7662e55ac3
ports:
- 8000:8000
options: --mount type=bind,source=${{ github.workspace }},target=/opt/CTFd/CTFd/plugins/ctfd-chall-manager
env:
DATABASE_URL: mysql+pymysql://root:ctfer@mariadb/ctfd
LOG_LEVEL: DEBUG
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Wait for CTFd server
run: |
max_attempts=60
base_url="http://localhost:8000"
for ((i=0; i<$max_attempts; i++)); do
if curl --head --fail --silent --show-error "$base_url" >/dev/null; then
echo "Server is up and running!"
break
else
echo "Waiting for the server to respond... (attempt $((i+1)))"
sleep 5
fi
done
if [ $i -eq $max_attempts ]; then
echo "Server did not respond within the allotted time. Exiting..."
exit 1
fi
- name: Wait for Chall-Manager server
run: |
max_attempts=60
base_url="http://localhost:8080/api/v1/challenge"
for ((i=0; i<$max_attempts; i++)); do
if curl --fail --silent --show-error "$base_url" >/dev/null; then
echo "Server is up and running!"
break
else
echo "Waiting for the server to respond... (attempt $((i+1)))"
sleep 5
fi
done
if [ $i -eq $max_attempts ]; then
echo "Server did not respond within the allotted time. Exiting..."
exit 1
fi
- name: Setup CTFd
uses: ctfer-io/ctfd-setup@f76c764b07af9c6292de3f75009876e26c77bb1f # v1.2.1
with:
url: 'http://ctfd:8000'
appearance_name: CTFer.io
appearance_description: CTFer.io plugin tests
mode: teams
admin_name: ${{ env.NAME }}
admin_email: [email protected]
admin_password: ${{ env.PASSWORD }}
- name: Setup Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
- name: Generate token and store it for GH Actions
run: |-
cd hack/token
go run main.go
env:
CTFD_URL: http://localhost:8000
CTFD_NAME: ${{ env.NAME }}
CTFD_PASSWORD: ${{ env.PASSWORD }}
- name: Install pulumi
uses: pulumi/actions@ccd8e6d0d14d7ead561274adf8837a016b9c4f4e # 5.4.0
- name: Additionnal configuration for CTFd (users and teams)
run: |-
cd hack/config
pulumi login --local
pulumi stack init tmp
pulumi up --yes --stack tmp
env:
PULUMI_CONFIG_PASSPHRASE: ""
CTFD_URL: http://localhost:8000
# go build -o monbinaire mon/path/vers/main.go => go build -o main main.go entre le cd et le zip
- name: Generate demo-deploy.zip for tests
run: |-
cd hack/deploy
zip ${{ github.workspace }}/demo-deploy.zip main
zip ${{ github.workspace }}/demo-deploy.zip Pulumi.yaml
env:
CGO_ENABLED: 0
GOPRIVATE: github.com/ctfer-io/chall-manager # remove when chall-manager will be released
- name: tests with cypress
uses: cypress-io/github-action@df7484c5ba85def7eef30db301afa688187bc378 # v6.7.2
env:
CYPRESS_CTFD_NAME: ${{ env.NAME }}
CYPRESS_CTFD_PASSWORD: ${{ env.PASSWORD }}
CYPRESS_CTFD_URL: "http://localhost:8000"
CYPRESS_SCENARIO_PATH: "${{ github.workspace }}/demo-deploy.zip"
CYPRESS_PLUGIN_SETTINGS_CM_API_URL: "http://chall-manager:8080/api/v1"
CYPRESS_PLUGIN_SETTINGS_CM_MANA_TOTAL: "10"
- uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # 4.3.6
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
if-no-files-found: ignore