Skip to content

Commit 547c893

Browse files
committed
feat: refactor for better tests (#90)
* feat: refactor for better tests Refactors the code to add a basic funcionality check of the podman module for our usecasea * feat: refactor for CI before deploy
1 parent 2d88e51 commit 547c893

24 files changed

Lines changed: 168 additions & 78 deletions
Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Deploy Microservices
1+
name: Continuous Integration
22

33
on:
44
push:
@@ -12,6 +12,7 @@ on:
1212
- 'schedule-manager/**'
1313
- 'scraper/**'
1414
- 'schedule-optimizer/**'
15+
- 'nix/**'
1516

1617
jobs:
1718
check-changes:
@@ -258,7 +259,7 @@ jobs:
258259
docker tag $LOCAL_IMAGE $REMOTE_LATEST_IMAGE
259260
docker push $REMOTE_LATEST_IMAGE
260261
261-
deploy:
262+
integration-test:
262263
runs-on: ubuntu-latest
263264
needs:
264265
- build-client
@@ -269,6 +270,23 @@ jobs:
269270
- build-schedule-optimizer
270271
if: always()
271272
steps:
273+
- uses: actions/checkout@v4
274+
- uses: cachix/install-nix-action@v25
275+
with:
276+
nix_path: nixpkgs=channel:nixos-unstable
277+
- uses: cachix/cachix-action@v14
278+
with:
279+
name: team-nixops
280+
# If you chose API tokens for write access OR if you have a private cache
281+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
282+
- run: nix flake check -L --option sandbox false --no-pure-eval
283+
284+
deploy:
285+
runs-on: ubuntu-latest
286+
needs:
287+
- integration-test
288+
if: always()
289+
steps:
272290
- name: Configure SSH
273291
run: |
274292
mkdir -p ~/.ssh/

.github/workflows/infra.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,61 @@ jobs:
2222
- name: Extract microservice name from tag
2323
id: extract
2424
run: |
25-
# Tag format: microservice@vX.Y.Z
26-
TAG=${GITHUB_REF#refs/tags/}
27-
MICROSERVICE="${TAG%@*}"
28-
echo "Microservice: $MICROSERVICE"
29-
echo "::set-output name=microservice::$MICROSERVICE"
30-
- run: nix build .#${{ steps.extract.outputs.microservice }}.dockerImage
31-
- name: Log in to GitHub Container Registry
32-
uses: docker/login-action@v3
33-
with:
34-
registry: ghcr.io
35-
username: ${{ github.actor }}
36-
password: ${{ secrets.GITHUB_TOKEN }}
37-
- name: Run release for microservice
38-
run: |
39-
echo "Releasing microservice: ${{ steps.extract.outputs.microservice }}"
40-
version=$(nix eval --raw .#${{ steps.extract.outputs.microservice }}.version)
41-
name=$(nix eval --raw .#${{ steps.extract.outputs.microservice }}.pname)
42-
LOCAL_IMAGE="nixops-${name}:${version}"
43-
REMOTE_VERSIONED_IMAGE="ghcr.io/aet-devops25/nixops-${name}:${version}"
44-
docker load < result
45-
docker tag $LOCAL_IMAGE $REMOTE_VERSIONED_IMAGE
46-
docker push $REMOTE_VERSIONED_IMAGE
25+
#TODO: add schedule-optimizer on merging https://github.com/AET-DevOps25/team-nixops/pull/39
26+
COMPONENTS=("client" "embedding-bridge" "genai" "schedule-manager" "scraper")
27+
for name in "${COMPONENTS[@]}"; do
28+
version=$(nix eval --raw ".#${name}.version")
29+
tag="${name}@v${version}"
30+
if git rev-parse "$tag" >/dev/null 2>&1; then
31+
echo "${name}=false" >> $GITHUB_OUTPUT
32+
else
33+
echo "${name}=true" >> $GITHUB_OUTPUT
34+
fi
35+
done
36+
release-client:
37+
needs: check-versions
38+
if: needs.check-versions.outputs.new_client == 'true'
39+
uses: ./.github/workflows/z-release-service.yml
40+
with:
41+
microservice: client
42+
43+
release-embedding-bridge:
44+
needs: check-versions
45+
if: needs.check-versions.outputs.new_embedding_bridge == 'true'
46+
uses: ./.github/workflows/z-release-service.yml
47+
with:
48+
microservice: embedding-bridge
49+
50+
release-genai:
51+
needs: check-versions
52+
if: needs.check-versions.outputs.new_genai == 'true'
53+
uses: ./.github/workflows/z-release-service.yml
54+
with:
55+
microservice: genai
56+
57+
release-schedule-manager:
58+
needs: check-versions
59+
if: needs.check-versions.outputs.new_schedule_manager == 'true'
60+
uses: ./.github/workflows/z-release-service.yml
61+
with:
62+
microservice: schedule-manager
63+
64+
release-scraper:
65+
needs: check-versions
66+
if: needs.check-versions.outputs.new_scraper == 'true'
67+
uses: ./.github/workflows/z-release-service.yml
68+
with:
69+
microservice: scraper
70+
71+
release-schedule-optimizer:
72+
needs: check-versions
73+
if: needs.check-versions.outputs.new_schedule_optimizer == 'true'
74+
uses: ./.github/workflows/z-release-service.yml
75+
with:
76+
microservice: schedule-optimizer
77+
78+
lint-helm:
79+
uses: ./.github/workflows/z-lint-helm.yml
4780

4881
deploy-staging:
4982
runs-on: ubuntu-latest

nix/README.md

Whitespace-only changes.

nix/checks/default.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
...
55
}: {
66
nixos-k8s = pkgs.testers.runNixOSTest {
7-
imports = [./k8s.nix];
7+
imports = [./k8s];
88
node.specialArgs = {inherit self;};
99
};
10+
nixos-podman = pkgs.testers.runNixOSTest {
11+
imports = [./podman];
12+
};
1013
}

0 commit comments

Comments
 (0)