-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (130 loc) · 5.27 KB
/
main.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Template for rapids.ai
on: [push]
env:
REGISTRY: ghcr.io
jobs:
build:
name: Code Analysis
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: ['3.10']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f ${{ github.workspace }}/.devcontainer/requirements.txt ]; then pip install -r ${{ github.workspace }}/.devcontainer/requirements.txt; fi
if [ -f ${{ github.workspace }}/.devcontainer/extra.txt ]; then pip install -r ${{ github.workspace }}/.devcontainer/extra.txt; fi
- name: Lint with flake8
run: |
printf "\n"
echo "============================= flake8 session starts =============================="
printf "\n"
# stop the build if there are Python syntax errors or undefined names
printf "\n"
echo "Issues in relation to logic (F7), syntax (Python E9, Flake F7), mathematical
formulae symbols (F63), undefined variable names (F82):"
printf "\n src/algorithms "
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics src/algorithms
printf "\n src/functions "
flake8 --count --select=E9,F63,F7,F82 --show-source --statistics src/functions
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
printf "\n\n"
echo "Complexity issues:"
printf "\n src/algorithms "
flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics src/algorithms
printf "\n src/functions "
flake8 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics src/functions
- name: Lint with pylint
run: |
printf "\n"
echo "============================= pylint session starts =============================="
printf "\n Package src/algorithms"
pylint --rcfile .pylintrc src/algorithms
printf "\n Package src/functions"
pylint --rcfile .pylintrc src/functions
- name: Test with pytest
run: |
printf "\n"
echo "============================= pytest session starts =============================="
printf "\n pytest tests/algorithms/test_example.py"
# pytest -o python_files=test_example.py
- name: Coverage with pytest-cov
run: |
printf "\n "
echo "============================= coverage session starts =============================="
printf "\n Coverage tests/algorithms/"
# pytest --cov-report term-missing --cov src/algorithms/ tests/algorithms/
packages:
name: GitHub Packages Container Registry
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Logging into GitHub Container
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build & Push
shell: bash
env:
REPOSITORY: ${{ github.repository }}
IMAGE_TAG: ${{ steps.meta.outputs.tags }}
run: |
docker build . --file Dockerfile --tag "$REGISTRY/$REPOSITORY:$IMAGE_TAG"
docker push ${{ env.REGISTRY }}/${{ env.REPOSITORY }}:${{ env.IMAGE_TAG }}
ecr:
name: Amazon Elastic Container Registry
needs: build
if: ${{ true }}
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::${{ secrets.AWS_ENTRY }}:role/${{ secrets.AWS_ARN_ECR_ACTIONS }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
registries: ${{ secrets.AWS_ENTRY }}
mask-password: "true"
- name: Build, tag, and push image to Amazon ECR
id: build-publish
shell: bash
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: 'patterns'
IMAGE_TAG: ${{ github.event.repository.name }}
run: |
docker build . --file Dockerfile --tag "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
echo "An image has been pushed to $ECR_REGISTRY/$ECR_REPOSITORY"
echo "The image tag is $IMAGE_TAG"