Skip to content

Commit

Permalink
Release 0.9.0 "pear" (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
yscialom committed Dec 13, 2022
2 parents 9d5c02a + 30b9ed3 commit 200bcbf
Show file tree
Hide file tree
Showing 90 changed files with 3,655 additions and 715 deletions.
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: type:bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environment (please complete the following information):**
- PiNanas Server
-- Hardware [e.g. Raspberry Pi 4 8GB, Intel amd64 CPU, ...]
-- OS: [e.g. Debian]
-- Version [e.g. 0.4.0]
- Client
-- OS
-- Browser [e.g. chrome, safari]
-- Is it specific to smartphones or desktop PCs?

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: type:enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
72 changes: 72 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "develop", master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "develop" ]
schedule:
- cron: '27 1 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
128 changes: 128 additions & 0 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Continuous Deployment

on:
workflow_dispatch: ~
push:
branches:
- develop


jobs:
undeploy:
name: Undeploy
runs-on: ubuntu-latest
environment: uat
steps:
- name: Adding Known Hosts
run: mkdir -p ~/.ssh && ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary

- name: Clean workspace
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "rm -rf ~/pinanas-src"

- name: Stop previous PiNanas
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "if [[ -f ~/pinanas/docker-compose.yml ]] ; then cd ~/pinanas && docker-compose down ; fi"

- name: Remove docker containers, volumes, networks and images
run: |
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker container prune --force"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker volume prune --force"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker network prune --force"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker image prune --force --all"
- name: Remove installation directory
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "sudo rm -rf -- ~/pinanas/"

deploy:
name: Deploy
runs-on: ubuntu-latest
environment: uat
needs: undeploy
steps:
- name: Adding Known Hosts
run: mkdir -p ~/.ssh && ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary

- name: Clone
uses: actions/checkout@v2

- name: Recreate directories
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "mkdir -p ~/pinanas-src ~/pinanas"

- name: Deploy to PiNanas UAT
run: scp -P ${{ secrets.SSH_PORT }} -r * ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:~/pinanas-src/.

configure:
name: Configure
runs-on: ubuntu-latest
environment: uat
needs: deploy
steps:
- name: Adding Known Hosts
run: mkdir -p ~/.ssh && ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary

- name: Prepare settings from secrets
env:
settings_pinanas_master_secret: "${{ secrets.settings_pinanas_master_secret }}"
settings_pinanas_johndoe_password: "${{ secrets.settings_pinanas_johndoe_password }}"
settings_pinanas_network_dns_provider_api: "${{ secrets.settings_pinanas_network_dns_provider_api }}"
settings_pinanas_network_dns_provider_email: "${{ secrets.settings_pinanas_network_dns_provider_email }}"
settings_pinanas_network_dns_provider_name: "${{ secrets.settings_pinanas_network_dns_provider_name }}"
settings_pinanas_network_smtp_host: "${{ secrets.settings_pinanas_network_smtp_host }}"
settings_pinanas_network_smtp_password: "${{ secrets.settings_pinanas_network_smtp_password }}"
settings_pinanas_network_smtp_port: "${{ secrets.settings_pinanas_network_smtp_port }}"
settings_pinanas_network_smtp_sender: "${{ secrets.settings_pinanas_network_smtp_sender }}"
settings_pinanas_network_smtp_username: "${{ secrets.settings_pinanas_network_smtp_username }}"
run: |
env | grep ^settings_pinanas_ | ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "cat >~/.ssh/environment"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "envsubst <~/pinanas-src/test/settings-cd.yml >~/pinanas/settings.yml"
- name: Configure
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "cd ~/pinanas && ~/pinanas-src/src/configure.sh && rm ~/.ssh/environment"

start:
name: Start
runs-on: ubuntu-latest
environment: uat
needs: configure
steps:
- name: Adding Known Hosts
run: mkdir -p ~/.ssh && ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary

- name: Start
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "cd ~/pinanas && docker-compose up -d && ~/pinanas-src/test/wait-for-containers.sh ."

- name: Import Let's Encrypt stagging root CA
run: |
echo -n "Nexcloud... "
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "curl -o ~/pinanas/nextcloud/data/files/letsencrypt-stg-root-x1.crt https://letsencrypt.org/certs/staging/letsencrypt-stg-root-x1.pem"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker exec nextcloud occ security:certificates:import /data/letsencrypt-stg-root-x1.crt"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "rm -f ~/pinanas/nextcloud/data/files/letsencrypt-stg-root-x1.crt"
echo "OK"
echo -n "Jellyfin... "
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker exec jellyfin mkdir -p /usr/share/ca-certificates/misc"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker exec jellyfin curl -o /usr/share/ca-certificates/misc/letsencrypt-stg-root-x1.crt https://letsencrypt.org/certs/staging/letsencrypt-stg-root-x1.pem"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker exec jellyfin bash -c 'echo misc/letsencrypt-stg-root-x1.crt >> /etc/ca-certificates.conf'"
ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "docker exec jellyfin update-ca-certificates"
echo "OK"
- name: Distclean
run: ssh -p ${{ secrets.SSH_PORT }} ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} -C "cd ~/pinanas && ./distclean.sh"
69 changes: 69 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Continuous Integration

on:
workflow_dispatch: ~
pull_request: ~
push:
branches:
- develop
- release/**
tags:
- v**


#TODO: split in jobs and use encrypted artefacts
# - artefacts: https://docs.github.com/en/actions/advanced-guides/storing-workflow-data-as-artifacts
# - encrypt: https://www.tecmint.com/encrypt-decrypt-files-tar-openssl-linux/
# - cache?
jobs:
build:
name: "Build & Test"
runs-on: ubuntu-latest

steps:
- name: "Prepare test environment: Disable DNS cache server to free 53/udp up"
run: |
sudo mkdir -p /etc/systemd/resolved.conf.d
echo -e '[Resolve]\nDNSStubListener=no' | sudo tee -a /etc/systemd/resolved.conf.d/disable-for-pinanas.conf
sudo systemctl force-reload systemd-resolved
sudo rm /etc/resolv.conf
sudo ln -s ../run/systemd/resolve/resolv.conf /etc/resolv.conf
- name: "Prepare test environment: download Let's Encrypt's staging root certificate"
run: curl -o /tmp/letsencrypt-stg-root-x1.pem 'https://letsencrypt.org/certs/staging/letsencrypt-stg-root-x1.pem'

- name: Clone
uses: actions/checkout@v2

- name: Prepare settings from secrets
env:
settings_pinanas_master_secret: "${{ secrets.settings_pinanas_master_secret }}"
settings_pinanas_network_dns_provider_api: "${{ secrets.settings_pinanas_network_dns_provider_api }}"
settings_pinanas_network_dns_provider_email: "${{ secrets.settings_pinanas_network_dns_provider_email }}"
settings_pinanas_network_dns_provider_name: "${{ secrets.settings_pinanas_network_dns_provider_name }}"
settings_pinanas_network_smtp_host: "${{ secrets.settings_pinanas_network_smtp_host }}"
settings_pinanas_network_smtp_password: "${{ secrets.settings_pinanas_network_smtp_password }}"
settings_pinanas_network_smtp_port: "${{ secrets.settings_pinanas_network_smtp_port }}"
settings_pinanas_network_smtp_sender: "${{ secrets.settings_pinanas_network_smtp_sender }}"
settings_pinanas_network_smtp_username: "${{ secrets.settings_pinanas_network_smtp_username }}"
run: |
mkdir dist
envsubst <test/settings-ci.yml >dist/settings.yml
- name: Configure
run: cd dist && ../src/configure.sh

- name: Start
run: |
cd dist
docker-compose up -d
timeout 180 ../test/wait-for-containers.sh && sleep 120 # to be replaced by compose v2 --wait option
- name: Test dhcpd configuration file
run: test/test-dhcpd.sh dist

- name: Test Traefik dashboard
run: test/test-traefik-dashboard.sh dist

- name: Test Nextcloud
run: test/test-nextcloud-install.sh dist
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*~
build/
\#*\#
/build/
/dist/
Loading

0 comments on commit 200bcbf

Please sign in to comment.