-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (110 loc) · 3.43 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
name: Challenges Build Test
run-name: ${{ github.head_ref }} Challenge | ${{ github.event.pull_request.user.login }}
on:
pull_request:
branches:
- 'main'
workflow_dispatch:
######################
env:
DIRECTORY: challenges
README_FILE: README.md
######################
jobs:
test:
name: 'Test Challenge Structure'
if: github.head_ref != 'dev'
defaults:
run:
shell: bash
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Python Setup
uses: actions/setup-python@v5
with:
python-version: '3.11.7'
- name: Test Challenge directory structure
run: .github/scripts/chall_structure_validator.py $DIRECTORY/${{github.head_ref}}
######################
test_deployability:
name: 'Check Deployability'
defaults:
run:
shell: bash
outputs:
deploy_env: ${{ steps.deployable.outputs.deploy_env }}
runs-on: ubuntu-latest
needs: test
if: success()
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: 'Dockerfile Existance'
id: 'deployable'
run : .github/scripts/deployability_checker.sh $DIRECTORY/${{ github.head_ref }}
- name: 'Check Output'
run: echo "${{steps.deployable.outputs.deploy_env}}"
######################
build_dockerfile:
name: 'Build Challenge Image using Dockerfile'
needs: test_deployability
if: needs.test_deployability.outputs.deploy_env == 'Dockerfile'
defaults:
run:
shell: bash
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: 'Checkout'
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Build Challenge Image
run: docker buildx build $DIRECTORY/${{github.head_ref}}/ --load -t "$(echo ${{github.head_ref}} | tr -t '[A-Z]' '[a-z]')":latest
- name: Launch Container
run: docker run -d "$(echo ${{github.head_ref}} | tr -t '[A-Z]' '[a-z]')":latest
- name: Check Running Container
run: docker ps -a
######################
build_docker-compose:
name: 'Start Challenge using Docker Compose'
needs: test_deployability
if: needs.test_deployability.outputs.deploy_env == 'docker-compose'
defaults:
run:
shell: bash
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Docker Compose Challenge Deployment
uses: hoverkraft-tech/[email protected]
with:
compose-file: ${{ env.DIRECTORY }}/${{ github.head_ref }}/docker-compose.yml
up-flags: "--build"
- name: Test Challenge
run: docker ps -a
######################
check_readme_file_table:
name: 'Check Challs in Readme File'
if: github.head_ref != 'dev'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: 'Checkout'
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: 'Comparaison Number of Challs between Table and within Directory'
run: .github/scripts/readme_file_checker.sh $DIRECTORY $README_FILE