forked from PacktPublishing/Graph-Machine-Learning
-
Notifications
You must be signed in to change notification settings - Fork 1
139 lines (121 loc) · 4.28 KB
/
ci.yaml
File metadata and controls
139 lines (121 loc) · 4.28 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Build Image
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
pull_request:
workflow_call:
jobs:
build:
strategy:
fail-fast: false
max-parallel: 5
matrix:
chapter:
- name: chap1
folder: Chapter01
- name: chap2
folder: Chapter02
- name: chap3
folder: Chapter03
- name: chap4
folder: Chapter04
- name: chap5
folder: Chapter05
- name: chap6
folder: Chapter06
- name: chap7
folder: Chapter07
- name: chap8
folder: Chapter08
- name: chap9
folder: Chapter09
- name: chap10
folder: Chapter10
- name: chap12
folder: Chapter12
runs-on: ubuntu-22.04
name: Image ${{ matrix.chapter.name }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: (GitHub hosted) Free up disk space
shell: bash
run: |
printf '\nDisk usage before cleanup\n'
df --human-readable
# Based on https://github.com/actions/runner-images/issues/2840#issuecomment-790492173
rm -r /usr/share/dotnet
rm -r /opt/hostedtoolcache/
printf '\nDisk usage after cleanup\n'
df --human-readable
- name: Build Image
id: build
run: |
cd docker
docker build . --target ${{ matrix.chapter.name }} \
--build-arg branch=${{ steps.extract_branch.outputs.branch }} \
-t graph-machine-learning:latest --no-cache
- name: Test Image
id: tests
env:
KAGGLE_USERNAME: ${{ secrets.KAGGLE_USERNAME }}
KAGGLE_TOKEN: ${{ secrets.KAGGLE_TOKEN }}
run: |
docker network create my-network
# Start Neo4j and JanusGraph if we are testing chapter 10
if [ "${{ matrix.chapter.name }}" == "chap10" ];
then
docker run --rm --detach --name janusgraph \
--publish=8182:8182 \
janusgraph/janusgraph:1.1.0
docker network connect my-network janusgraph
docker run --rm --detach --name neo4j \
--publish=7474:7474 --publish=7687:7687 \
--user="$(id -u):$(id -g)" \
--env NEO4J_AUTH=none \
--env NEO4J_PLUGINS='["graph-data-science"]' \
neo4j:5.26.0
docker network connect my-network neo4j
fi
# Start Neo4j if we are testing chapter 13
if [ "${{ matrix.chapter.name }}" == "chap12" ];
then
docker run --rm --detach --name neo4j \
--publish=7474:7474 --publish=7687:7687 \
--user="$(id -u):$(id -g)" \
--env NEO4J_AUTH=none \
--env NEO4J_PLUGINS='["apoc","apoc-extended"]' \
--env NEO4J_apoc_export_file_enabled=true \
--env NEO4J_apoc_import_file_enabled=true \
--env NEO4J_apoc_import_file_use__neo4j_config=true \
neo4j:5.26.0
docker network connect my-network neo4j
docker run --rm --detach --name ollama \
--publish=11434:11434 \
--volume olama:/root/.ollama \
ollama/ollama:0.6.4
docker network connect my-network ollama
fi
mkdir -p data
chmod -R 777 data
docker run \
--rm --detach -v "$(pwd)/data:/data" \
--name graph-machine-learning-box \
--env KAGGLE_USERNAME=${KAGGLE_USERNAME} \
--env KAGGLE_KEY=${KAGGLE_TOKEN} \
--env NEO4J_HOST=neo4j \
--env JANUSGRAPH_HOST=janusgraph \
--env OLLAMA_HOST=ollama \
graph-machine-learning:latest
docker network connect my-network graph-machine-learning-box
# Run tests
cd docker
./tests.sh ${{ matrix.chapter.folder }}
- name: tmate session if tests fail
if: failure() && github.event_name == 'workflow_dispatch'
uses: mxschmitt/action-tmate@v3