Skip to content

Commit

Permalink
Merge pull request #2211 from MiczFlor/future3/develop
Browse files Browse the repository at this point in the history
Release v3.5.0
  • Loading branch information
pabera authored Feb 4, 2024
2 parents 6088ad2 + 20389e3 commit 92b4c4b
Show file tree
Hide file tree
Showing 169 changed files with 10,528 additions and 2,142 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = test/*
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ shared
src/webapp/node_modules
src/webapp/npm-debug.log
src/webapp/build
src/webapp/build.bak
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ indent_size = 4
[*.md]
trim_trailing_whitespace = false

[*.{js,yaml}]
[*.{js,yaml,yml}]
indent_size = 2
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ extend-exclude =
scratch*,
# Ignore dirs and files that have not been ported yet
*/jukebox/NvManager.py
# ignore GitHub Codespaces
# ignore Python venv's
.venv/*
# ignore node modules
*/node_modules/*
24 changes: 20 additions & 4 deletions .githooks/post-merge
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# TO ACTIVATE: cp .githooks/post-merge .git/hooks/.
#
# Checks:
# - Changes to web app
# - Changes to Web App
# - Changes to web dependency
# - Changes to python requirements
#
Expand All @@ -20,7 +20,7 @@ warn_npm_dependency() {
echo "************************************************************"
echo "ATTENTION: npm dependencies have changed since last pull!"
echo ""
echo "To update dependencies and rebuilt WebApp run:"
echo "To update dependencies and rebuilt Web App run:"
echo "$ cd src/webapp && ./run_rebuild.sh -u"
echo "************************************************************"
echo -e "\n"
Expand All @@ -31,7 +31,7 @@ warn_webapp() {
echo "************************************************************"
echo "ATTENTION: Web App sources have changed since last pull!"
echo ""
echo "To rebuilt the WebApp run:"
echo "To rebuilt the Web App run:"
echo "$ cd src/webapp && ./run_rebuild.sh"
echo "************************************************************"
echo -e "\n"
Expand All @@ -43,6 +43,7 @@ warn_python_requirements() {
echo "ATTENTION: Python requirements have changed since last pull!"
echo ""
echo "To update python requirements on the RPi run"
echo "$ source .venv/bin/activate"
echo "$ python -m pip install --upgrade -r requirements.txt"
echo "************************************************************"
echo -e "\n"
Expand All @@ -57,14 +58,25 @@ warn_githooks() {
echo "$ cp .githooks/* .git/hooks/."
echo "************************************************************"
echo -e "\n"
}

warn_installer() {
echo -e "\n"
echo "************************************************************"
echo "ATTENTION: Installer sources have changed since last pull!"
echo ""
echo "Rerun the installer to apply changes"
echo "$ ./installation/install-jukebox.sh"
echo "************************************************************"
echo -e "\n"
}

# files_changed="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
webapp_changed="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD src/webapp)"
webapp_dep_changed="$(git diff --name-only --no-commit-id ORIG_HEAD HEAD src/webapp/package.json)"
python_req_changed="$(git diff --name-only --no-commit-id ORIG_HEAD HEAD requirements.txt)"
githooks_changed="$(git diff --name-only --no-commit-id ORIG_HEAD HEAD .githooks)"
installer_changed="$(git diff --name-only --no-commit-id ORIG_HEAD HEAD installation)"

if [[ -n $python_req_changed ]]; then
warn_python_requirements
Expand All @@ -80,5 +92,9 @@ if [[ -n $githooks_changed ]]; then
warn_githooks
fi

if [[ -n $installer_changed ]]; then
warn_installer
fi

echo -e "\nTo see a summary of what happened since your last pull, do:"
echo -e "git show --oneline -s ORIG_HEAD..HEAD\n"
echo -e "git show --oneline -s ORIG_HEAD..HEAD\n"
14 changes: 13 additions & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Checks
# - flake8 on staged python files
# Note: This only checks the modified files
# - docs build of if any python file or any doc file is staged
# - docs build of if any python file is staged
# Note: This builds the entire documentation if a changed file goes into the documentation
#
# If there are problem with this script, commit may still be done with
Expand All @@ -28,6 +28,18 @@ fi

code=$(( flake8_code ))

doc_code=0
if [[ -n $PY_FILES ]]; then
echo -e "\n**************************************************************"
echo -e "Modified Python source files. Generation markdown docs from docstring ... \n"
echo -e "**************************************************************\n"
./run_docgeneration.sh -c
doc_code=$?
echo "pydoc_markdown return code: $doc_code"
fi

code=$(( flake8_code + doc_code ))

if [[ code -gt 0 ]]; then
echo -e "\n**************************************************************"
echo -e "ERROR(s) during pre-commit checks. Aborting commit!"
Expand Down
25 changes: 25 additions & 0 deletions .github/actions/build-webapp/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build Web App
description: 'Build Web App with Node'
inputs:
webapp-root-path:
description: 'root path of the Web App sources'
required: false
default: './src/webapp'
outputs:
webapp-root-path:
description: 'used root path of the Web App sources'
value: ${{ inputs.webapp-root-path }}

runs:
using: "composite"
steps:
- name: Setup Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: run build
working-directory: ${{ inputs.webapp-root-path }}
shell: bash
env:
CI: false
run: ./run_rebuild.sh -u
171 changes: 171 additions & 0 deletions .github/workflows/bundle_webapp_and_release_v3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: Bundle Web App and Release

on:
push:
branches:
- 'future3/main'
- 'future3/develop'

jobs:

check:
if: ${{ github.repository_owner == 'MiczFlor' }}
runs-on: ubuntu-latest

outputs:
tag_name: ${{ steps.vars.outputs.tag_name }}
release_type: ${{ steps.vars.outputs.release_type }}
check_abort: ${{ steps.vars.outputs.check_abort }}

steps:
- uses: actions/checkout@v4

- name: Set Output vars
id: vars
env:
BRANCH_NAME: ${{ github.ref_name }}
run: |
# Official SemVer Regex definition
# https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
# Needed changes to the regex:
# - '?:' capture command needed to be removed as it wasn't working in shell
# - '\d' had to be replaced with [0-9]
#
# Release versions like 1.0.0, 3.5.0, 100.4.50000+metadata
REGEX_VERSION_RELEASE="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$"
#
# Prerelease versions like 1.0.0-alpha, 3.5.0-whatsoever.12, 100.4.50000-identifier.12+metadata
REGEX_VERSION_PRERELEASE="^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$"
# Get the version and calculate release type
VERSION=$(python ./src/jukebox/jukebox/version.py)
if echo "$VERSION" | grep -qoE "$REGEX_VERSION_RELEASE" ; then
RELEASE_TYPE=release
elif echo "$VERSION" | grep -qoE "$REGEX_VERSION_PRERELEASE" ; then
RELEASE_TYPE=prerelease
else
RELEASE_TYPE=none
fi
if [ "$BRANCH_NAME" == 'future3/main' -a "$RELEASE_TYPE" == 'release' ] || [ "$BRANCH_NAME" == 'future3/develop' -a "$RELEASE_TYPE" == 'prerelease' ] ; then
CHECK_ABORT=false
else
echo "::notice title=Abort due to not matching ${RELEASE_TYPE} version for branch!::'${VERSION}' on '${BRANCH_NAME}'"
CHECK_ABORT=true
fi
echo "::group::Output values"
echo "Version: ${VERSION}"
echo "RELEASE_TYPE: ${RELEASE_TYPE}"
echo "BRANCH_NAME: ${BRANCH_NAME}"
echo "CHECK_ABORT: ${CHECK_ABORT}"
echo "tag_name=v${VERSION}" >> $GITHUB_OUTPUT
echo "release_type=${RELEASE_TYPE}" >> $GITHUB_OUTPUT
echo "branch_name=${BRANCH_NAME}" >> $GITHUB_OUTPUT
echo "check_abort=${CHECK_ABORT}" >> $GITHUB_OUTPUT
echo "::endgroup::"
build:
needs: [check]
if: ${{ needs.check.outputs.check_abort == 'false' }}
runs-on: ubuntu-latest

outputs:
tag_name: ${{ needs.check.outputs.tag_name }}
release_type: ${{ needs.check.outputs.release_type }}
commit_sha: ${{ steps.vars.outputs.commit_sha }}
webapp_bundle_name: ${{ steps.vars.outputs.webapp_bundle_name }}
webapp_bundle_name_latest: ${{ steps.vars.outputs.webapp_bundle_name_latest }}

steps:
- uses: actions/checkout@v4

- name: Set Output vars
id: vars
env:
COMMIT_SHA: ${{ github.sha }}
run: |
echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "webapp_bundle_name=webapp-build-${COMMIT_SHA:0:10}.tar.gz" >> $GITHUB_OUTPUT
echo "webapp_bundle_name_latest=webapp-build-latest.tar.gz" >> $GITHUB_OUTPUT
- name: Build Web App
id: build-webapp
uses: ./.github/actions/build-webapp

- name: Create Bundle
working-directory: ${{ steps.build-webapp.outputs.webapp-root-path }}
run: |
tar -czvf ${{ steps.vars.outputs.webapp_bundle_name }} build
- name: Artifact Upload
uses: actions/upload-artifact@v3
with:
name: ${{ steps.vars.outputs.webapp_bundle_name }}
path: ${{ steps.build-webapp.outputs.webapp-root-path }}/${{ steps.vars.outputs.webapp_bundle_name }}
retention-days: 5

release:
needs: [build]
runs-on: ubuntu-latest

concurrency:
group: ${{ needs.build.outputs.tag_name }}

permissions:
contents: write

steps:
- name: Artifact Download
uses: actions/download-artifact@v3
with:
name: ${{ needs.build.outputs.webapp_bundle_name }}

- name: Create Release
uses: ncipollo/release-action@v1
with:
commit: ${{ needs.build.outputs.commit_sha }}
tag: ${{ needs.build.outputs.tag_name }}
body: "Automated Release for ${{ needs.build.outputs.tag_name }}"
makeLatest: 'false'
prerelease: ${{ needs.build.outputs.release_type == 'prerelease' }}
generateReleaseNotes: ${{ needs.build.outputs.release_type == 'release' }}
skipIfReleaseExists: false
allowUpdates: true
removeArtifacts: false
replacesArtifacts: false
omitBodyDuringUpdate: true
omitNameDuringUpdate: true
token: ${{ secrets.GITHUB_TOKEN }}

- name: Get Release by tag
id: get_release
uses: joutvhu/get-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.build.outputs.tag_name }}

- name: Upload Release Asset
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_name: ${{ needs.build.outputs.webapp_bundle_name }}
asset_path: ${{ needs.build.outputs.webapp_bundle_name }}
asset_content_type: application/gzip
overwrite: true

- name: Upload Release Asset as Latest
uses: shogo82148/actions-upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_name: ${{ needs.build.outputs.webapp_bundle_name_latest }}
asset_path: ${{ needs.build.outputs.webapp_bundle_name }}
asset_content_type: application/gzip
overwrite: true
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: "CodeQL v3"

on:
push:
branches: [ develop ]
branches: [ future3/develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
branches: [ future3/develop ]
schedule:
- cron: '16 18 * * 0'

Expand All @@ -35,22 +35,40 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
# Install necessary packages
sudo apt-get install libasound2-dev pulseaudio
python3 -m venv .venv
source ".venv/bin/activate"
python -m pip install --upgrade pip
pip install -r requirements.txt
# Set the `CODEQL-PYTHON` environment variable to the Python executable
# that includes the dependencies
echo "CODEQL_PYTHON=$(which python)" >> $GITHUB_ENV
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
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.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
setup-python-dependencies: false

# 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@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -64,4 +82,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
Loading

0 comments on commit 92b4c4b

Please sign in to comment.