2024-01-04 20:07:57 +00:00
|
|
|
name: Django CI Pipeline
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- release
|
|
|
|
- testing-pipeline
|
2024-01-31 09:55:09 +00:00
|
|
|
pull_request:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
- release
|
2024-01-04 20:07:57 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-01-14 16:33:35 +00:00
|
|
|
test:
|
2024-01-04 20:07:57 +00:00
|
|
|
|
2024-01-31 08:48:50 +00:00
|
|
|
runs-on: self-hosted
|
2024-01-04 20:07:57 +00:00
|
|
|
|
2024-01-14 16:33:35 +00:00
|
|
|
env:
|
2024-01-14 19:12:17 +00:00
|
|
|
SECRET_KEY: "t3st-dummy-s3cr3t-k3y"
|
2024-01-14 19:16:20 +00:00
|
|
|
STATIC_ROOT: "tmp/static/"
|
|
|
|
MEDIA_ROOT: "tmp/media/"
|
2024-03-04 18:14:43 +00:00
|
|
|
DOMAIN: "testserver"
|
2024-01-14 16:33:35 +00:00
|
|
|
|
2024-01-04 20:07:57 +00:00
|
|
|
steps:
|
2024-01-04 20:20:32 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-01-04 20:07:57 +00:00
|
|
|
|
2024-01-25 11:05:45 +00:00
|
|
|
- name: Check version and distribution
|
|
|
|
run: |
|
|
|
|
uname -srm
|
2024-01-25 11:07:14 +00:00
|
|
|
cat /etc/os-release
|
2024-01-25 11:05:45 +00:00
|
|
|
|
2024-01-12 08:49:08 +00:00
|
|
|
- name: Install python3-venv
|
2024-01-12 09:00:13 +00:00
|
|
|
id: install
|
2024-01-12 08:49:08 +00:00
|
|
|
run: |
|
2024-01-12 09:18:14 +00:00
|
|
|
apt-get update
|
2024-01-25 11:39:20 +00:00
|
|
|
apt-get install python3 python3-venv python3-pip -y
|
2024-01-12 09:18:14 +00:00
|
|
|
|
|
|
|
- name: Check Python version
|
|
|
|
run: |
|
|
|
|
python3 --version
|
2024-01-12 08:49:08 +00:00
|
|
|
|
2024-01-12 08:47:44 +00:00
|
|
|
- name: Create virtual environment
|
|
|
|
run: |
|
|
|
|
python3 -m venv venv
|
|
|
|
source venv/bin/activate
|
2024-01-12 09:25:00 +00:00
|
|
|
echo "Virtual environment created successfully"
|
2024-01-12 09:00:13 +00:00
|
|
|
# https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context
|
|
|
|
if: steps.install.outcome == 'success'
|
2024-01-12 08:47:44 +00:00
|
|
|
|
2024-01-25 10:43:47 +00:00
|
|
|
- name: Get DIDKit wheel
|
|
|
|
id: didkit
|
|
|
|
run: |
|
2024-02-12 21:22:48 +00:00
|
|
|
wget -O didkit-0.3.2-cp311-cp311-manylinux_2_34_x86_64.whl https://gitea.pangea.org/api/v1/repos/trustchain-oc1-orchestral/ssikit_trustchain/raw/didkit-0.3.2-cp311-cp311-manylinux_2_34_x86_64.whl?token=${{ secrets.FILE_GETTER_TOKEN }}
|
2024-01-25 10:43:47 +00:00
|
|
|
echo "Successfully downloaded DIDkit"
|
|
|
|
|
2024-01-12 08:47:44 +00:00
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
2024-01-12 09:25:00 +00:00
|
|
|
source venv/bin/activate
|
2024-01-25 11:51:46 +00:00
|
|
|
which python
|
|
|
|
pip -V
|
2024-01-12 08:47:44 +00:00
|
|
|
pip install --upgrade pip
|
2024-01-25 11:51:46 +00:00
|
|
|
pip -V
|
|
|
|
python -V
|
2024-01-12 08:47:44 +00:00
|
|
|
pip install -r requirements.txt
|
2024-01-25 10:43:47 +00:00
|
|
|
if: steps.didkit.outcome == 'success'
|
2024-01-12 08:47:44 +00:00
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: |
|
|
|
|
source venv/bin/activate
|
2024-03-06 11:36:26 +00:00
|
|
|
coverage run manage.py test
|
|
|
|
coverage report
|
|
|
|
# python manage.py test
|
2024-01-04 20:07:57 +00:00
|
|
|
|
2024-02-29 16:47:24 +00:00
|
|
|
ssikit-tests:
|
|
|
|
needs: test
|
|
|
|
runs-on: self-hosted
|
|
|
|
steps:
|
|
|
|
|
|
|
|
- name: Checkout SSIKit repo
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
2024-02-29 16:51:51 +00:00
|
|
|
repository: trustchain-oc1-orchestral/ssikit_trustchain
|
2024-02-29 16:47:24 +00:00
|
|
|
submodules: true
|
2024-02-29 17:55:04 +00:00
|
|
|
ref: master
|
2024-02-29 17:08:46 +00:00
|
|
|
# might not be needed
|
2024-02-29 17:25:10 +00:00
|
|
|
token: ${{ secrets.SSIKIT_TOKEN }}
|
2024-02-29 16:47:24 +00:00
|
|
|
|
|
|
|
- name: Install python3-venv (if not already installed)
|
|
|
|
run: |
|
2024-02-29 17:58:33 +00:00
|
|
|
apt-get update
|
|
|
|
apt-get install python3 python3-venv python3-pip -y
|
2024-02-29 16:47:24 +00:00
|
|
|
|
|
|
|
- name: Setup Python environment
|
|
|
|
run: |
|
|
|
|
python3 -m venv venv
|
|
|
|
source venv/bin/activate
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
source venv/bin/activate
|
|
|
|
pip install --upgrade pip
|
|
|
|
# Install any additional dependencies required for SSIKit tests here
|
2024-02-29 17:08:46 +00:00
|
|
|
pip install -r requirements.txt
|
2024-02-29 16:47:24 +00:00
|
|
|
|
|
|
|
- name: Execute SSIKit tests
|
|
|
|
run: |
|
|
|
|
source venv/bin/activate
|
|
|
|
python main.py
|
2024-02-01 20:04:08 +00:00
|
|
|
|
|
|
|
deploy:
|
|
|
|
needs: test
|
|
|
|
runs-on: self-hosted
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2024-02-02 08:21:19 +00:00
|
|
|
|
2024-02-01 20:04:08 +00:00
|
|
|
- name: Trigger Remote Script
|
|
|
|
run: |
|
2024-02-01 20:21:10 +00:00
|
|
|
response=$(curl -s -o /dev/null -w "%{http_code}" -X POST http://45.150.187.54:5000/trigger-script -H "Authorization: SecretToken")
|
2024-02-01 20:05:28 +00:00
|
|
|
if [ "$response" -ne 200 ]; then
|
2024-02-01 20:04:08 +00:00
|
|
|
echo "Script execution failed with HTTP status $response"
|
|
|
|
exit 1
|
2024-02-01 20:21:10 +00:00
|
|
|
else
|
|
|
|
echo "Script execution successful"
|
|
|
|
exit 0
|
2024-02-01 20:05:28 +00:00
|
|
|
fi
|
2024-02-29 16:24:35 +00:00
|
|
|
if: success() && github.ref == 'refs/heads/release'
|