Skip to content

Blueprint of Shelly Plus 2PM #678

Blueprint of Shelly Plus 2PM

Blueprint of Shelly Plus 2PM #678

name: Blueprints Linter
on:
pull_request_target:
branches: [main]
jobs:
linting:
name: Blueprints Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Get Changed Files
id: changes
run: |
echo "changed-files=$(git diff --name-only ${{ github.event.pull_request.head.sha }} ${{ github.sha }} | xargs)" >> "$GITHUB_OUTPUT"
- name: Security Check
run: |
if [ ${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }} ]; then
if echo ${{ steps.changes.outputs.changed-files }} | grep .scripts &> /dev/null; then
echo "::error::scripts changes is not allowed"
exit 1
elif echo ${{ steps.changes.outputs.changed-files }} | grep .github &> /dev/null; then
echo "::error::workflow changes is not allowed"
exit 1
fi
fi
- name: Check Category
run: ./.scripts/category_checker.sh
- name: Check Vendors
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run marketplace_vendors_checker \
-p /marketplace \
-r ${{ github.event.pull_request.head.repo.full_name }} \
-b "$BRANCH" \
${{ steps.changes.outputs.changed-files }}
- name: Check Devices
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run marketplace_devices_checker \
-p /marketplace \
${{ steps.changes.outputs.changed-files }}
- name: Get Changed Blueprints Paths
id: paths
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run blueprints_collector -p /marketplace ${{ steps.changes.outputs.changed-files }} >> "$GITHUB_OUTPUT"
- name: Run Linter
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
--env ENAPTER_API_TOKEN=${{ secrets.ENAPTER_API_TOKEN }} \
docker.enapter.com/tools/blueprints-linter:v0.4.2 run -g -m ${{ steps.paths.outputs.blueprints-paths }}
- name: Check Blueprint Vendor
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run blueprint_vendor_checker -vp ./.marketplace/vendors/vendors.yml ${{ steps.paths.outputs.blueprints-paths }}
- name: Check Device Blueprint Link
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run device_blueprint_link_checker \
-p /marketplace \
${{ steps.paths.outputs.blueprints-paths }}