Skip to content

Merge pull request #634 from okp4/dependabot/github_actions/tj-action… #936

Merge pull request #634 from okp4/dependabot/github_actions/tj-action…

Merge pull request #634 from okp4/dependabot/github_actions/tj-action… #936

Workflow file for this run

name: Lint
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
name: Create build context
runs-on: ubuntu-22.04
outputs:
matrix-genesis: ${{ steps.matrix-genesis.outputs.config }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Find changed genesis files
id: changed-genesis
uses: tj-actions/[email protected]
with:
separator: ","
files: |
chains/*/genesis.json
- name: Setup matrix (for changed genesis)
id: matrix-genesis
run: |
CONFIG=""
ALL_MODIFIED_FILES="${{ steps.changed-genesis.outputs.all_modified_files }}"
IFS=',' read -r -a GENESISFILES <<< "$ALL_MODIFIED_FILES"
for GENESISFILE in "${GENESISFILES[@]}"; do
APATH=$(dirname ${GENESISFILE})
NETWORK=$(basename ${APATH})
NAME=$(basename ${GENESISFILE})
CONFIG="${CONFIG:+${CONFIG}, }{\"path\": \"${APATH}\", \"network\": \"${NETWORK}\", \"name\": \"${NAME}\"}"
done
echo "config=[${CONFIG}]" >> $GITHUB_OUTPUT
lint-commits:
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check commits
uses: wagoid/commitlint-github-action@v5
lint-markdown:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint markdown files
uses: avto-dev/[email protected]
with:
args: "**/*.md"
lint-yaml:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint yaml files
uses: ibiqlik/[email protected]
lint-json:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Lint json files
run: |
sudo apt install -y jsonlint
find ./ -type f -name "*.json" -exec sh -c '
for file do
if ! jsonlint-php -q "$file"; then
echo "❌ $file"
export FAILED=1
else
echo "✅ $file"
fi
done
if [ "${FAILED}" = "1" ]; then
exit 1
fi
' sh {} +
lint-genesis:
if: needs.prepare.outputs.matrix-genesis != '[]'
runs-on: ubuntu-22.04
needs: prepare
strategy:
matrix:
context: ${{ fromJson(needs.prepare.outputs.matrix-genesis) }}
fail-fast: false
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Check genesis files
run: |
echo "🔎 Checking 'okp4-${{ matrix.context.network }}' genesis"
docker run --rm -v ${GITHUB_WORKSPACE}/${{ matrix.context.path }}/${{ matrix.context.name }}:/genesis.json okp4/okp4d:`cat ./chains/${{ matrix.context.network }}/version.txt` validate-genesis /genesis.json