-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (107 loc) · 3.56 KB
/
build-and-test.yml
File metadata and controls
134 lines (107 loc) · 3.56 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
name: Build and Test
# on:
# workflow_call:
# push:
# branches-ignore: [dev, master]
on:
push:
# branches:
# - dev
# - feature/*
branches: [dev, master, feature/*, release/*]
pull_request:
branches: ['*']
jobs:
build:
name: Install Dependency with Poetry
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
id: Build-Poetry
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: 3.11
cache: poetry
- name: Install Python dependencies
run: poetry install
test:
name: Run tests
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install poetry
id: Build-Poetry-for-tests
run: pipx install poetry
- uses: actions/setup-python@v4
with:
python-version: 3.9
cache: poetry
- name: Install dependencies
run: poetry install
- name: Build Image for ES7
id: Build-elasticsearch
uses: docker/build-push-action@v4
with:
target: omni_es
tags: bees-omnisearch-es7:omni_es
# cache-from: type=gha
# cache-to: type=gha,mode=max
# build-args: AWS_ECR_ACCOUNT_URL=${{ vars.FN_ECR_REGISTRY_URL }}
# push: false
# load: true
- name: Run ES7
run: |
docker run --name bees-omnisearch-es7 -d --publish 9201:9201 --expose 9201 -e node.name=fn-dm-bees-omni-data-01 -e discovery.type=single-node -e http.port=9201 -e http.cors.enabled=true -e http.cors.allow-origin=* -e http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization -e http.cors.allow-credentials=true -e xpack.security.enabled=false -e bootstrap.system_call_filter=false -e ES_JAVA_OPTS="-Xms1g -Xmx1g" bees-omnisearch-es7:omni_es
- name: Run tests
id: Build-tests
run: poetry run pytest -sv ./tests
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: htmlcov
build-docker:
name: Build and Push to DockerHub
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Docker meta
id: docker-build
uses: docker/metadata-action@v4
with:
# images: euiyoung/fastapi-docker-github-actions:es
images: $IMAGE_NAME:es
# - name: Login to Docker Hub
# if: github.event_name != 'pull_request'
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Build and push Docker image
# uses: docker/build-push-action@v4
# with:
# context: src
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
alert:
name: Slack-Alerts
needs: build-docker
# if: ${{ github.event.workflow_run.conclusion == 'failure' }}
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Post to a Slack channel
uses: act10ns/slack@v1
with:
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
channel: '#alert'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()