Skip to content

Commit

Permalink
feat(common): move externaly accessible workflows out of .github/work…
Browse files Browse the repository at this point in the history
…flows so they can be generated in github action

BREAKING CHANGE: change path of workflows
DEPRECATED: flavor input option - use flavored workflow instead

Merge pull request #3 from biosustain/fix_flovors_pipeline

Fix flavours pipeline
  • Loading branch information
Skitionek committed Aug 21, 2024
2 parents a2aacfd + 9e4284e commit 6ef25b3
Show file tree
Hide file tree
Showing 21 changed files with 45 additions and 75 deletions.
36 changes: 24 additions & 12 deletions .github/workflows/prepare-flavours.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Update flavours
name: Update workflows

on:
workflow_dispatch:
Expand All @@ -7,40 +7,52 @@ on:
- main
paths:
- ".github/workflows/code-quality-check.yml"
- ".github/workflows/flavors/**"
- ".github/workflows/prepare-flavours.yml"
- "bin/prepare-flavors.sh"
- "flavors/*.yml"
- "code-quality-check.yml"

permissions:
contents: write
workflows: write

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}

jobs:
update-flavours:
name: Update flavours code quality checks
update-workflows:
name: Update external code quality workflow
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}

- name: Update core workflow
run: |
cp .github/workflows/code-quality-check.yml .
- name: Update flavours code quality checks
run: |
mkdir -p .github/workflows/flavors
mkdir -p flavors
for flavor in c_cpp ci_light cupcake documentation dotnet dotnetweb formatters go java javascript php python ruby rust salesforce security swift terraform
do
echo "::group::${flavor}"
sed -e "s|oxsecurity/megalinter|oxsecurity/megalinter/flavors/${flavor}|" .github/workflows/code-quality-check.yml > .github/workflows/flavors/${flavor}-code-quality-check.yml
echo "Updated .github/workflows/flavors/${flavor}-code-quality-check.yml"
sed -e "s|oxsecurity/megalinter|oxsecurity/megalinter/flavors/${flavor}|" .github/workflows/code-quality-check.yml > flavors/${flavor}-code-quality-check.yml
echo "Updated flavors/${flavor}-code-quality-check.yml"
echo "::endgroup::"
done
- name: Commit report
- name: Check for changes
id: check_changes
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> "$GITHUB_OUTPUT";
fi
- name: Commit updated workflows
if: steps.check_changes.outputs.changes
run: |
git config user.name "github-actions[bot]"
git config user.email "${{ github.workflow }}+github-actions[bot]@users.noreply.github.com"
git diff --exit-code || git commit -am "Automated report" && git push
git add .
git commit -m "Autogenerated workflows update"
git push
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
jobs:
code-quality-check:
name: Code quality check
uses: biosustain/code-quality-check/.github/workflows/code-quality-check.yml@latest
uses: biosustain/code-quality-check/code-quality-check.yml@latest
```
Alternatively, for better performance one can use specific [megalinter flavour](https://megalinter.io/latest/flavors/).
Expand All @@ -34,5 +34,5 @@ on:
jobs:
code-quality-check:
name: Code quality check
uses: biosustain/code-quality-check/.github/workflows/flavors/python-code-quality-check.yml@latest
uses: biosustain/code-quality-check/flavors/python-code-quality-check.yml@latest
```
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ on:
required: false
default: "{}" # Empty JSON object
type: string
FLAVOR:
description: |
You can override MegaLinter flavor used to have faster performances
More info at https://megalinter.io/flavors/
required: false
default: all
type: string
workflow_dispatch:
inputs:
JSON_ENV:
Expand All @@ -26,33 +19,6 @@ on:
required: false
default: "{}" # Empty JSON object
type: string
FLAVOR:
description: |
You can override MegaLinter flavor used to have faster performances
More info at https://megalinter.io/flavors/
required: false
default: all
type: choice
options:
- all
- c_cpp
- ci_light
- cupcake
- documentation
- dotnet
- dotnetweb
- formatters
- go
- java
- javascript
- php
- python
- ruby
- rust
- salesforce
- security
- swift
- terraformg

# Trigger the workflow also on push or pull request in this repository
push:
Expand All @@ -76,10 +42,6 @@ concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

env:
MEGALINT_VERSION: v7.10.0 # Cannot pin this version since we use multiple flavors
MEGALINT_FLAVOR: ${{ (inputs.FLAVOR && inputs.FLAVOR != 'all') && format('/flavors/{0}', inputs.FLAVOR) || '' }}

jobs:
check-code-quality:
name: Run MegaLinter to check code quality
Expand Down Expand Up @@ -115,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: jenseng/dynamic-uses@5175289a9a87978dcfcb9cf512b821d23b2a53eb # v1
uses: oxsecurity/[email protected]
id: ml
env:
# All available variables are described in documentation
Expand All @@ -137,10 +99,6 @@ jobs:
}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# You can override MegaLinter flavor used to have faster performances
# More info at https://megalinter.io/flavors/
uses: oxsecurity/megalinter/flavors/${flavor}${{ env.MEGALINT_FLAVOR }}@${{ env.MEGALINT_VERSION }}

# Upload MegaLinter artifacts
- name: Archive production artifacts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/c_cpp@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/ci_light@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/cupcake@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/documentation@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/dotnet@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/dotnetweb@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/formatters@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/go@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/java@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/javascript@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/php@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/python@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/ruby@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/rust@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/salesforce@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/security@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/swift@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
# MegaLinter
- name: MegaLinter
uses: oxsecurity/megalinter/flavors/${flavor}@v7.10.0
uses: oxsecurity/megalinter/flavors/terraform@v7.10.0
id: ml
env:
# All available variables are described in documentation
Expand Down

0 comments on commit 6ef25b3

Please sign in to comment.