Skip to content

Commit 1ccbd34

Browse files
committed
Setup CI workflow
1 parent a37a4bb commit 1ccbd34

5 files changed

Lines changed: 81 additions & 8 deletions

File tree

.github/workflows/makefile.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Makefile CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches: [ "main" ]
7+
8+
jobs:
9+
build:
10+
runs-on: macos-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Install dependencies
15+
run: make build
16+
17+
- name: Upload artifacts
18+
uses: actions/upload-artifact@v4
19+
with:
20+
name: build-artifacts
21+
path: ${{ github.workspace }}/.venv/
22+
if-no-files-found: error
23+
include-hidden-files: true
24+
25+
test-mac:
26+
runs-on: macos-latest
27+
needs: build
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Download artifacts
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: build-artifacts
35+
path: ${{ github.workspace }}/.venv/
36+
37+
- name: Restore executable permissions to .venv
38+
run: chmod -R u+x .venv/bin
39+
40+
- name: Bundle Mac App
41+
run: make macapp
42+
43+
- name: Verify Mac App
44+
run: ./dist/ekosuite.app/Contents/MacOS/ekosuite --validate-build
45+
46+
test:
47+
runs-on: macos-latest
48+
needs: build
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Download artifacts
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: build-artifacts
56+
path: ${{ github.workspace }}/.venv/
57+
58+
- name: Restore executable permissions to .venv
59+
run: chmod -R u+x .venv/bin
60+
61+
- name: Run Tests
62+
run: make test

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ SHELL := /bin/bash
44
# Define variables
55
VENV_DIR = .venv
66
PYTHON = $(VENV_DIR)/bin/python3
7+
PYTEST = $(VENV_DIR)/bin/pytest
78
PIP = $(VENV_DIR)/bin/pip3
89

910
# Targets
@@ -30,7 +31,7 @@ macapp:
3031
$(PYTHON) "$(VENV_DIR)/bin/PyInstaller" ekosuite.spec
3132

3233
test:
33-
pytest tests/
34+
$(PYTEST) tests/
3435

3536
run:
3637
$(PYTHON) ekosuite.py

ekosuite.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ async def main():
1717
sys.exit()
1818

1919
if __name__ == "__main__":
20+
args = sys.argv[1:]
21+
if args:
22+
if '--validate-build' in args:
23+
sys.exit(0)
2024
asyncio.run(main())

tests/test_image_db.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@
66
import asyncio
77
from datetime import datetime
88

9-
def _cleanup():
10-
for filename in os.listdir(testdata.test_data_folder()):
11-
file_path = os.path.join(testdata.test_data_folder(), filename)
12-
if os.path.isfile(file_path):
13-
os.remove(file_path)
14-
159
@pytest.fixture(autouse=True)
1610
def setup_before_each_test():
17-
_cleanup()
11+
testdata.cleanup()
1812
yield
1913
# _cleanup()
2014

tests/testdata.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import os
33
import time
4+
import shutil
45
import numpy as np
56
from datetime import datetime
67
from astropy.nddata import CCDData
@@ -12,6 +13,17 @@
1213
def test_data_folder():
1314
return os.path.join(os.path.dirname(__file__), "__data__")
1415

16+
def cleanup():
17+
folder = test_data_folder()
18+
if not os.path.exists(folder):
19+
return
20+
for filename in os.listdir(folder):
21+
file_path = os.path.join(folder, filename)
22+
if os.path.isfile(file_path):
23+
os.remove(file_path)
24+
elif os.path.isdir(file_path):
25+
shutil.rmtree(file_path, ignore_errors=True)
26+
1527
def create_test_fits(filename='test_image.fits',
1628
shape=(100, 100),
1729
date=datetime.now(),

0 commit comments

Comments
 (0)