Skip to content

Commit

Permalink
Add info.xml lint to replace occ app:check
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Dec 10, 2021
1 parent e27bd4c commit adea14f
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/dispatch-npm-engines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This workflow needs to be run on demand
# It will search for all repositories containing the provided
# action and open pull requests if necessary.

name: Update npm engines versions

on:
workflow_dispatch:

jobs:
repositories:
runs-on: ubuntu-latest

outputs:
matrix: ${{ steps.search-repos.outputs.matrix }}

steps:
- name: Check actor permission
uses: skjnldsv/check-actor-permission@v2
with:
require: admin

- name: Search repositories using a package.json
id: search-repos
# This is a simple curl to fetch the list of repos containing a file and extracting the repo names
# We check if the file is <50KB to ignore the lockfile
run: |
echo '' > repos.json
# Retrieve first 10 potential results pages
for i in {0..10}; do
RESULTS=$(curl -H "Accept: application/vnd.github.v3+json" "https://api.github.com/search/code?q=org%3A${{ github.repository_owner }}+size%3A<50000+filename%3Apackage.json&per_page=100&page=$i" | jq -c '.items')
if [ "$RESULTS" = "null" ]; then
echo "Stopped on page $i"
break
fi
echo "$RESULTS" >> repos.json
done
# Pipe all results arrays and filter duplicate
REPOS=$(cat repos.json | jq '.[]' | jq -sc 'map(.repository.name) | unique')
echo "::set-output name=matrix::$REPOS"
dispatch:
runs-on: ubuntu-latest
needs: repositories

strategy:
fail-fast: false
matrix:
repositories: ${{ fromJSON(needs.repositories.outputs.matrix) }}

env:
NODE_VERSION: "^14.0.0"
NPM_VERSION: "^7.0.0"

steps:
- name: Checkout target repository
uses: actions/checkout@v2
with:
repository: ${{ github.repository_owner }}/${{ matrix.repositories }}

- name: Set node version to ${{ env.NODE_VERSION }}
run: jq --tab '.engines.node = "${{ env.NODE_VERSION }}"' package.json > package-new.json && mv package-new.json package.json

- name: Set npm version to ${{ env.NPM_VERSION }}
run: jq --tab '.engines.npm = "${{ env.NPM_VERSION }}"' package.json > package-new.json && mv package-new.json package.json

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
body: Automated update of the npm and node engines versions
branch: feat/package-node-npm-engines-update
commit-message: Update npm and node engines versions
committer: Nextcloud bot <bot@nextcloud.com>
author: Nextcloud bot <bot@nextcloud.com>
signoff: true
title: Update npm and node engines versions
labels: dependencies
token: ${{ secrets.COMMAND_BOT_PAT }}
8 changes: 8 additions & 0 deletions workflow-templates/lint-info-xml.properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "Linting info.xml",
"description": "info.xml app linting based on the app-info template",
"iconName": "lint-info-xml",
"categories": [
"XML"
]
}
1 change: 1 addition & 0 deletions workflow-templates/lint-info-xml.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions workflow-templates/lint-info-xml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow is provided via the organization template repository
#
# https://github.com/nextcloud/.github
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization

name: Lint

on:
pull_request:
push:
branches:
- master
- stable*

jobs:
xml-linters:
runs-on: ubuntu-latest

name: info.xml lint
steps:
- name: Checkout
uses: actions/checkout@master

- name: Download schema
run: wget https://raw.githubusercontent.com/nextcloud/server/master/resources/app-info-shipped.xsd

- name: Lint info.xml
uses: ChristophWurst/xmllint-action@v1
with:
xml-file: ./appinfo/info.xml
xml-schema-file: ./app-info-shipped.xsd

0 comments on commit adea14f

Please sign in to comment.