-
-
Notifications
You must be signed in to change notification settings - Fork 276
167 lines (154 loc) · 5.2 KB
/
build.yml
File metadata and controls
167 lines (154 loc) · 5.2 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
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
166
167
name: build package & server
on:
pull_request:
push:
branches: [master]
jobs:
python-test:
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.9", "3.12", "3.13"]
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
pip install hatch==1.13.0 hatchling==1.25.0
- name: Test package
run: |
hatch run +py=${{ matrix.python-version }} test:package
build-conda:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ github.sha }}
- name: set version
run: |
python3 .github/pyproject_versions.py --replace True
- name: Build conda package
uses: prefix-dev/rattler-build-action@v0.2.16
with:
build-args: --channel codecarbon --channel conda-forge --output-dir /tmp/conda-bld
recipe-path: .conda/recipe.yaml
upload-artifact: false
test-conda:
runs-on: ubuntu-24.04
needs: [ build-conda ]
steps:
# Checkout needed to get github.sha
- uses: actions/checkout@v4
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: codecarbon
miniforge-version: latest
python-version: 3.12
use-mamba: true
- name: Restore build
uses: actions/cache@v4
with:
path: /tmp/conda-bld
key: build-conda-${{ github.sha }}
fail-on-cache-miss: true
- name: Install package
shell: bash -l {0}
run: mamba install --channel file:///tmp/conda-bld --channel codecarbon codecarbon
- name: Test conda package
shell: bash -l {0}
run: codecarbon --help
build_server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Clean pip cache
run: pip cache purge
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Unit tests on api
run: |
pip install hatch==1.13.0 hatchling==1.25.0
# hatch run api:test-unit
test_api_server:
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres:16
# Provide the password for postgres
env:
POSTGRES_DB: codecarbon_db
POSTGRES_PASSWORD: supersecret
POSTGRES_USER: codecarbon-user
POSTGRES_HOST: localhost
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5480:5432
steps:
# Downloads a copy of the code in your repository before running CI tests
- name: Check out repository code
uses: actions/checkout@v4
# Performs a clean installation of all dependencies
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install hatch==1.13.0 hatchling==1.25.0
- name: Setup PostgreSQL
# Runs a script that creates a PostgreSQL table, populates
# the table with data, and then retrieves the data.
run: hatch run api:setup-db
env:
# The hostname used to communicate with the PostgreSQL service container
DATABASE_URL: postgresql://codecarbon-user:supersecret@localhost:5480/codecarbon_db
- name: Run API tests
env:
CODECARBON_API_URL: http://localhost:8008
# The hostname used to communicate with the PostgreSQL service container
DATABASE_URL: postgresql://codecarbon-user:supersecret@localhost:5480/codecarbon_db
run: |
# hatch run api:server-ci &
sleep 2
# netstat -o -n -a | grep 8008
# hatch run api:test-integ
build-ui:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
working-directory: ./webapp
run: npm ci
- name: Build
working-directory: ./webapp
run: npm run build
- name: Check formatting with Prettier
working-directory: ./webapp
run: npx prettier . --check