Inkycal/.github/workflows/tests.yml

145 lines
4.2 KiB
YAML
Raw Normal View History

2023-01-20 01:09:13 +01:00
name: Inkycal testing
2020-05-16 08:22:57 +02:00
2023-01-20 01:09:13 +01:00
on:
push:
branches:
- main
2023-06-03 19:03:09 +02:00
2020-05-16 08:22:57 +02:00
jobs:
2023-06-03 19:53:42 +02:00
clone-setup-install:
name: Clone, Setup, and Install
2020-05-16 08:22:57 +02:00
runs-on: ubuntu-latest
steps:
2023-06-03 19:53:42 +02:00
- name: Checkout Repository
uses: actions/checkout@v3
2023-06-03 20:07:57 +02:00
with:
ref: main
2023-06-03 19:53:42 +02:00
2023-06-03 19:03:09 +02:00
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
2020-06-17 14:54:48 +02:00
2023-06-03 19:53:42 +02:00
- name: Install Dependencies
2023-06-03 19:03:09 +02:00
run: |
2023-06-03 19:53:42 +02:00
python3 -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
pip install wheel
2023-06-03 20:00:09 +02:00
pip install -e .
2023-06-03 20:31:58 +02:00
cd ..
2023-06-03 20:00:09 +02:00
2023-06-03 20:12:57 +02:00
- name: Create Archive
run: |
2023-06-03 20:39:11 +02:00
mkdir artefacts
tar -czf artefacts/workspace.tar.gz --exclude=./artefacts .
2023-06-03 20:12:57 +02:00
- name: Save Workspace Archive
2023-06-03 20:00:09 +02:00
uses: actions/upload-artifact@v2
with:
name: workspace
2023-06-03 20:41:01 +02:00
path: artefacts/workspace.tar.gz
2023-06-03 17:39:55 +02:00
2023-07-23 03:23:24 +02:00
test-on-arm:
name: Run Tests on Raspberry Pi OS
2023-06-03 19:53:42 +02:00
needs: clone-setup-install
runs-on: ubuntu-latest
2023-07-23 21:47:41 +02:00
permissions:
contents: write
2023-06-03 19:53:42 +02:00
steps:
2023-06-03 20:00:09 +02:00
- name: Restore Workspace
uses: actions/download-artifact@v2
with:
name: workspace
2023-06-03 19:53:42 +02:00
2023-06-03 20:12:57 +02:00
- name: Extract Workspace Archive
run: |
tar -xzf workspace.tar.gz
2023-07-23 03:23:24 +02:00
- name: Run Tests on Raspberry Pi OS
uses: pguyot/arm-runner-action@v2
2023-07-23 13:13:44 +02:00
id: build_image
2023-07-23 10:27:35 +02:00
env:
OPENWEATHERMAP_API_KEY: ${{ secrets.OPENWEATHERMAP_API_KEY }}
SAMPLE_ICAL_URL: ${{ secrets.SAMPLE_ICAL_URL }}
TEST_ICAL_URL: ${{ secrets.TEST_ICAL_URL }}
TODOIST_API_KEY: ${{ secrets.TODOIST_API_KEY }}
2023-07-23 03:23:24 +02:00
with:
# Set the base_image to the desired Raspberry Pi OS version
base_image: raspios_lite:latest
2023-07-23 03:31:06 +02:00
image_additional_mb: 2000 # enlarge free space to 2 GB
2023-07-23 03:23:24 +02:00
# Set the commands to run the tests
commands: |
2023-07-23 03:50:15 +02:00
apt-get update -y
apt-get install -y python3-pip
2023-07-23 09:43:35 +02:00
sudo apt-get install zlib1g libjpeg-dev libatlas-base-dev rustc libopenjp2-7 python3-dev scons libssl-dev python3-venv python3-pip git libfreetype6-dev -y
2023-07-23 03:39:26 +02:00
cd /Inkycal
. venv/bin/activate
2023-07-23 04:22:41 +02:00
python -m pip install --upgrade pip
pip install wheel
pip install -e ./
2023-07-23 03:23:24 +02:00
cd inkycal/tests
2023-07-23 03:39:26 +02:00
echo $PWD
2023-07-23 03:23:24 +02:00
wget https://raw.githubusercontent.com/aceinnolab/Inkycal/assets/tests/settings.json
for f in *.py; do python3 "$f"; done
2023-07-23 13:13:44 +02:00
- name: Compress the release image
run: |
mv ${{ steps.build_image.outputs.image }} inkycal_os.img
xz -0 -T 0 -v inkycal_os.img
ls
2023-07-23 20:46:24 +02:00
- name: Get latest release version
run: |
export tag="$(curl -s https://api.github.com/repos/aceinnolab/Inkycal/releases/latest | jq -r '.tag_name')"
echo "version=${tag}" >> $GITHUB_ENV
2023-07-23 03:23:24 +02:00
- name: Upload Raspberry Pi OS Image
if: success() # Only upload the image if the tests were successful
2023-07-23 13:13:44 +02:00
uses: softprops/action-gh-release@v1
2023-07-23 20:46:24 +02:00
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2023-07-23 03:23:24 +02:00
with:
2023-07-23 20:46:24 +02:00
tag_name: ${{ env.version }}
2023-07-23 22:59:52 +02:00
files: inkycal_os.img.xz
2023-06-03 19:53:42 +02:00
2023-07-24 00:07:08 +02:00
generate-and-publish-docs:
name: Generate and publish docs
2023-06-03 19:53:42 +02:00
needs: clone-setup-install
runs-on: ubuntu-latest
2023-07-24 00:07:08 +02:00
permissions:
contents: write
2023-06-03 19:53:42 +02:00
steps:
2023-07-24 01:53:11 +02:00
- uses: actions/download-artifact@v2
2023-06-03 20:00:09 +02:00
with:
name: workspace
2023-07-24 01:53:11 +02:00
2023-07-24 01:16:43 +02:00
- name: Extract Workspace Archive
run: |
tar -xzf workspace.tar.gz
2023-06-03 20:12:57 +02:00
2023-06-03 19:53:42 +02:00
- name: Generate Docs
run: |
2023-07-23 23:31:32 +02:00
sudo apt-get install python3-sphinx
2023-06-03 20:00:09 +02:00
source venv/bin/activate
2023-07-23 23:41:46 +02:00
pip install sphinxemoji sphinx_rtd_theme recommonmark
2023-06-03 22:04:23 +02:00
cd docsource
2023-07-24 00:07:08 +02:00
make html && make github && cd ..
2023-07-24 01:53:11 +02:00
git add docs/*
2023-07-24 01:16:43 +02:00
git status
2023-07-24 01:09:09 +02:00
- name: publish
run: |
2023-07-24 02:36:16 +02:00
git status
2023-07-24 01:16:43 +02:00
echo "$PWD"
ls
2023-07-24 02:36:16 +02:00
git config user.name github-actions
git config user.email github-actions@github.com
2023-07-24 02:41:56 +02:00
git remote set-url origin https://x-access-token:${{ secrets.ACTIONS_SECRET }}@github.com/$GITHUB_REPOSITORY
2023-07-24 01:23:04 +02:00
git add docs/*
2023-07-24 00:21:42 +02:00
git commit -m "update docs"
2023-07-24 02:41:56 +02:00
git push --force