Skip to content

Commit

Permalink
Add version mismatch detection, refactor GH workflows, draft release.…
Browse files Browse the repository at this point in the history
…yml, increase prettier scope (#250)

* Refactor GH workflows

* Add version mismatch checker and UpdateClient Dialog

* Fix finalize release workflow

* Increase prettier scope

* Increase prettier coverage, add some static to prettierignore

* Add CodeQL on PR
  • Loading branch information
Reckless-Satoshi committed Sep 22, 2022
1 parent e4ddeea commit 538f3cb
Show file tree
Hide file tree
Showing 45 changed files with 6,311 additions and 5,998 deletions.
45 changes: 41 additions & 4 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Android Build
on:
workflow_dispatch:
workflow_call:
inputs:
semver:
required: true
type: string
push:
branches: [ "main" , "android-webview-app-ts"]
branches: [ "main" ]
paths: [ "mobile", "frontend" ]
pull_request:
branches: [ "main" , "android-webview-app-ts"]
branches: [ "main" ]
paths: [ "mobile", "frontend" ]

jobs:
Expand Down Expand Up @@ -37,8 +42,40 @@ jobs:
id: commit
uses: pr-mpt/actions-commit-hash@v1

- name: 'Upload .apk Artifact'
- name: 'Upload .apk Artifact (for Release)'
uses: actions/upload-artifact@v3
if: inputs.semver != '' # If this workflow is called from release.yml
with:
name: robosats-${{ inputs.semver }}.apk
path: mobile/android/app/build/outputs/apk/release/app-release.apk

- name: 'Upload .apk Artifact (for Pre-release)'
uses: actions/upload-artifact@v3
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
with:
name: robosats-${{ steps.commit.outputs.short }}.apk
path: mobile/android/app/build/outputs/apk/release/app-release.apk
path: mobile/android/app/build/outputs/apk/release/app-release.apk

- name: 'Create Pre-release'
id: create_release
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: android-${{ steps.commit.outputs.short }}
release_name: robosats-alpha-${{ steps.commit.outputs.short }}
draft: false
prerelease: true

- name: 'Upload Pre-release APK Asset'
id: upload-release-asset
if: inputs.semver == '' # only if this workflow is not called from a push to tag (a Release)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./mobile/android/app/build/outputs/apk/release/app-release.apk
asset_name: robosats-${{ steps.commit.outputs.short }}.apk
asset_content_type: application/apk
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: Client App Image CI/CD

on:
workflow_dispatch:
workflow_call:
push:
branches: [ "main" ]
paths: ["frontend", "nodeapp"]
pull_request:
branches: [ "main" ]
paths: ["frontend", "nodeapp"]

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
# concurrency:
# group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
# cancel-in-progress: true

jobs:
push_to_registry:
Expand All @@ -20,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: 'Copy Static' # Only needed because Github actions does not support symlinks
- name: 'Copy Static' # Needed since Github actions does not support symlinks
run: |
rm nodeapp/static
cp -r frontend/static nodeapp/static
Expand All @@ -47,12 +48,13 @@ jobs:
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: 'Get Commit Hash'
id: commit
uses: pr-mpt/actions-commit-hash@v1
Expand All @@ -69,8 +71,6 @@ jobs:
context: ./nodeapp
platforms: linux/amd64,linux/arm64
push: true
tags: |
recksato/robosats-client:${{ steps.commit.outputs.short }}
recksato/robosats-client:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

75 changes: 75 additions & 0 deletions .github/workflows/codeql-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# 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 Analysis Client"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
paths:
- 'frontend'
- 'mobile'
schedule:
- cron: '39 10 * * 2'

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

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: "CodeQL Analysis Coordinator"

on:
push:
branches: [ "main" ]
pull_request:
# The branches below must be a subset of the branches above
# branches: [ "main" ]
branches: [ "main" ]
paths:
- 'api'
schedule:
- cron: '39 10 * * 2'

Expand All @@ -32,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
name: Backend Image CI
name: Coodinator Image CI

on:
workflow_dispatch:
push:
branches: [ "main" ]
paths: ["api", "chat", "control", "robosats", "frontend"]
pull_request:
branches: [ "main" ]
paths: ["api", "chat", "control", "robosats", "frontend"]
workflow_call:

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
# concurrency:
# group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
# cancel-in-progress: true

jobs:
push_to_registry:
Expand Down Expand Up @@ -42,10 +37,11 @@ jobs:
tags: |
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
- name: 'Get Commit Hash'
Expand All @@ -61,8 +57,6 @@ jobs:
with:
context: .
push: true
tags: |
recksato/robosats:${{ steps.commit.outputs.short }}
recksato/robosats:latest
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

9 changes: 5 additions & 4 deletions .github/workflows/django-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ name: Django Tests

on:
workflow_dispatch:
workflow_call:
push:
branches: [ "main" ]
paths: ["api", "chat", "control", "robosats"]
pull_request:
branches: [ "main" ]
paths: ["api", "chat", "control", "robosats"]

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
# concurrency:
# group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
# cancel-in-progress: true

jobs:
build:
Expand Down Expand Up @@ -55,4 +56,4 @@ jobs:
mv .env-sample .env
- name: 'Tests'
run: |
python manage.py test
python manage.py test
15 changes: 13 additions & 2 deletions .github/workflows/frontend-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: Frontend Test & Build

on:
workflow_dispatch:
workflow_call:
inputs:
semver:
required: true
type: string
push:
branches: [ "main" ]
paths: [ "frontend" ]
Expand Down Expand Up @@ -48,10 +53,16 @@ jobs:
with:
name: main-js
path: frontend/static/frontend/main.js
- name: 'Invoke Backend Build CI workflow'

invoke-docker-builds:
if: inputs.semver == ''
runs-on: ubuntu-latest
needs: build
steps:
- name: 'Invoke Coodinator Image CI'
uses: benc-uk/workflow-dispatch@v1
with:
workflow: 'Backend Image CI'
workflow: 'Coodinator Image CI'
token: ${{ secrets.PERSONAL_TOKEN }}
- name: 'Invoke Client App Build CI/CD workflow'
uses: benc-uk/workflow-dispatch@v1
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
with:
prettier: true
prettier_dir: frontend
# Many linting errors

## Disabled due to error
# eslint: true
# eslint_dir: frontend
Loading

0 comments on commit 538f3cb

Please sign in to comment.