From 6e9b4019a2b6f51cbf6fdadb1ceb706366b7d555 Mon Sep 17 00:00:00 2001 From: lagertonne Date: Wed, 6 Nov 2024 22:26:48 +0100 Subject: [PATCH 1/9] cicd: Deploy testing automatically --- .forgejo/workflows/testing.yml | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .forgejo/workflows/testing.yml diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml new file mode 100644 index 0000000..2237cf9 --- /dev/null +++ b/.forgejo/workflows/testing.yml @@ -0,0 +1,41 @@ +on: + push: + branches: + - testing +jobs: + deploy: + runs-on: docker + steps: + - uses: actions/checkout@v4 + - name: Install ansible + run: | + apt update -y + apt install python3-pip -y + python3 -m pip install ansible + python3 -m pip install ansible-lint + + - name: Populate relevant files + run: | + mkdir ~/.ssh + echo "${{ secrets.C3LF_SSH_TESTING }}" > ~/.ssh/id_ed25519 + chmod 0600 ~/.ssh/id_ed25519 + ls -lah ~/.ssh + command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y ) + eval $(ssh-agent -s) + ssh-add ~/.ssh/id_ed25519 + echo "andromeda.lab.or.it ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDXPoO0PE+B9PYwbGaLo98zhbmjAkp6eBtVeZe43v/+T" >> ~/.ssh/known_hosts + mkdir /etc/ansible + echo "${{ secrets.C3LF_INVENTORY_TESTING }}" > /etc/ansible/hosts + + - name: Check ansible version + run: | + ansible --version + + - name: List ansible hosts + run: | + ansible -m ping Andromeda + + - name: Deploy testing + run: | + cd deploy/ansible + ansible-playbook playbooks/deploy-c3lf-sys3.yml From 9f65113c3ab51a25d49436491bd1a045a324bb0a Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 20:49:17 +0100 Subject: [PATCH 2/9] cicd: Add testing --- .forgejo/workflows/testing.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 2237cf9..bee7aeb 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -2,7 +2,23 @@ on: push: branches: - testing + - feature/forgejo-actions jobs: + test: + runs-on: docker + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + cache: 'pip' + - name: Install needed python modules + working-directory: core + run: cd core && pip3 install -r requirements.prod.txt + - name: Run django tests + working-directory: core + run: python3 -m manage.py test + deploy: runs-on: docker steps: From 38cfe3d6866395d565f7a55bfedfc5c8f23e66f4 Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 21:05:37 +0100 Subject: [PATCH 3/9] Fix python version --- .forgejo/workflows/testing.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index bee7aeb..d53c269 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -6,11 +6,13 @@ on: jobs: test: runs-on: docker + container: + image: docker.io/node:20-bookworm steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.13' + python-version: 3.11 cache: 'pip' - name: Install needed python modules working-directory: core From 835de0ae467b98ab306c89c6cc39eb1fc15df575 Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 21:08:48 +0100 Subject: [PATCH 4/9] fix python module installation --- .forgejo/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index d53c269..f25d585 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -16,7 +16,7 @@ jobs: cache: 'pip' - name: Install needed python modules working-directory: core - run: cd core && pip3 install -r requirements.prod.txt + run: cd core && pip install -r requirements.prod.txt - name: Run django tests working-directory: core run: python3 -m manage.py test From 5908c1a1923c316651320c944c502c6a8121758c Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 21:09:52 +0100 Subject: [PATCH 5/9] Do not specify python version --- .forgejo/workflows/testing.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index f25d585..1e9d53f 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -12,7 +12,6 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.11 cache: 'pip' - name: Install needed python modules working-directory: core From e38cab8adde19852adf0b53681d12486963c1214 Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 21:13:25 +0100 Subject: [PATCH 6/9] Fix job dependencies --- .forgejo/workflows/testing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 1e9d53f..44e82f3 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -21,6 +21,7 @@ jobs: run: python3 -m manage.py test deploy: + needs: [test] runs-on: docker steps: - uses: actions/checkout@v4 From c0d8069097874c19286b67809e327d162ad061b1 Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 21:16:21 +0100 Subject: [PATCH 7/9] It seems we still need to specify python version? --- .forgejo/workflows/testing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 44e82f3..42267b6 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -12,6 +12,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: + python-version: '3.x' cache: 'pip' - name: Install needed python modules working-directory: core From 33631f4f2d08a9e6f5ccb34d19828f1945a27a5a Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 21:17:09 +0100 Subject: [PATCH 8/9] Fuck forgejo actions --- .forgejo/workflows/testing.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index 42267b6..f73b8a1 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -7,16 +7,16 @@ jobs: test: runs-on: docker container: - image: docker.io/node:20-bookworm + image: ghcr.io/catthehacker/ubuntu:act-22.04 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: '3.11' cache: 'pip' - name: Install needed python modules working-directory: core - run: cd core && pip install -r requirements.prod.txt + run: cd core && pip3 install -r requirements.prod.txt - name: Run django tests working-directory: core run: python3 -m manage.py test From 44af3a8715f43af27fc795809631b33e730ae1de Mon Sep 17 00:00:00 2001 From: lagertonne Date: Mon, 11 Nov 2024 21:36:02 +0100 Subject: [PATCH 9/9] Fix python dependency detection --- .forgejo/workflows/testing.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index f73b8a1..f58252e 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -13,13 +13,13 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.11' - cache: 'pip' - - name: Install needed python modules + cache-dependency-path: '**/requirements.prod.txt' + - name: Install dependencies working-directory: core - run: cd core && pip3 install -r requirements.prod.txt + run: pip3 install -r requirements.dev.txt - name: Run django tests working-directory: core - run: python3 -m manage.py test + run: python3 manage.py test deploy: needs: [test]