Skip to content

Commit

Permalink
chore: Add more ci
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Sep 24, 2024
1 parent d96b80a commit 0881144
Show file tree
Hide file tree
Showing 44 changed files with 8,736 additions and 81 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/lint-info-xml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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
#
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Lint info.xml

on: pull_request

permissions:
contents: read

concurrency:
group: lint-info-xml-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:

xml-linters:
runs-on: ubuntu-latest-low
strategy:
fail-fast: false
matrix:
APP_NAME: [ 'socialsharing_diaspora', 'socialsharing_email', 'socialsharing_facebook', 'socialsharing_telegram', 'socialsharing_twitter' ]


name: info.xml lint
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Download schema
run: wget https://raw.githubusercontent.com/nextcloud/appstore/master/nextcloudappstore/api/v1/release/info.xsd

- name: Lint info.xml
uses: ChristophWurst/xmllint-action@36f2a302f84f8c83fceea0b9c59e1eb4a616d3c1 # v1.2
with:
xml-file: ./${matrix.APP_NAME}/appinfo/info.xml
xml-schema-file: ./info.xsd
60 changes: 60 additions & 0 deletions .github/workflows/lint-php-cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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
#
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Lint php-cs

on: pull_request

permissions:
contents: read

concurrency:
group: lint-php-cs-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
APP_NAME: [ 'socialsharing_diaspora', 'socialsharing_email', 'socialsharing_facebook', 'socialsharing_telegram', 'socialsharing_twitter' ]


name: php-cs

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Get php version
id: versions
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
with:
filename: ./socialsharing_diaspora/appinfo/info.xml

- name: Set up php${{ steps.versions.outputs.php-available }}
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: ${{ steps.versions.outputs.php-available }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: |
cd ${matrix.APP_NAME}
composer remove nextcloud/ocp --dev
composer i
- name: Lint
run: |
cd ${matrix.APP_NAME}
composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
77 changes: 77 additions & 0 deletions .github/workflows/lint-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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
#
# SPDX-FileCopyrightText: 2021-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Lint php

on: pull_request

permissions:
contents: read

concurrency:
group: lint-php-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
matrix:
runs-on: ubuntu-latest-low
outputs:
php-versions: ${{ steps.versions.outputs.php-versions }}
steps:
- name: Checkout app
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Get version matrix
id: versions
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.0.0
with:
filename: ./socialsharing_diaspora/appinfo/info.xml

php-lint:
runs-on: ubuntu-latest
needs: matrix
strategy:
fail-fast: false
matrix:
php-versions: ${{fromJson(needs.matrix.outputs.php-versions)}}
APP_NAME: [ 'socialsharing_diaspora', 'socialsharing_email', 'socialsharing_facebook', 'socialsharing_telegram', 'socialsharing_twitter' ]


name: php-lint

steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up php ${{ matrix.php-versions }}
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: ${{ matrix.php-versions }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Lint
run: |
cd ${matrix.APP_NAME}
composer run lint
summary:
permissions:
contents: none
runs-on: ubuntu-latest-low
needs: php-lint

if: always()

name: php-lint-summary

steps:
- name: Summary status
run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi
102 changes: 102 additions & 0 deletions .github/workflows/psalm-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# 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
#
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: MIT

name: Static analysis

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

concurrency:
group: psalm-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
matrix:
runs-on: ubuntu-latest-low
outputs:
ocp-matrix: ${{ steps.merge-matrix.outputs.merged-matrix }}
steps:
- name: Checkout app
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Get version matrix
id: versions
uses: icewind1991/nextcloud-version-matrix@58becf3b4bb6dc6cef677b15e2fd8e7d48c0908f # v1.3.1
with:
filename: ./socialsharing_diaspora/appinfo/info.xml
# Merge the base matrix with custom elements
- name: Merge matrix with custom elements
id: merge-matrix
run: |
# Custom matrix elements you want to add
custom_matrix='{"APP_NAME": [ "socialsharing_diaspora", "socialsharing_email", "socialsharing_facebook", "socialsharing_telegram", "socialsharing_twitter" ]}'
# Base matrix from the previous job
base_matrix='${{ steps.versions.outputs.ocp-matrix }}'
# Merge the base matrix with custom matrix using jq
merged_matrix=$(echo "$base_matrix" | jq --argjson custom "$custom_matrix" '. + $custom')
# Set the merged matrix as the output
echo "::set-output name=merged-matrix::$merged_matrix"
static-analysis:
runs-on: ubuntu-latest
needs: matrix
strategy:
# do not stop on another job's failure
fail-fast: false
matrix: ${{ fromJson(needs.matrix.outputs.ocp-matrix) }}

name: static-psalm-analysis ${{ matrix.ocp-version }}
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up php${{ matrix.php-versions }}
uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # v2.31.1
with:
php-version: ${{ matrix.php-versions }}
extensions: bz2, ctype, curl, dom, fileinfo, gd, iconv, intl, json, libxml, mbstring, openssl, pcntl, posix, session, simplexml, xmlreader, xmlwriter, zip, zlib, sqlite, pdo_sqlite
coverage: none
ini-file: development
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: |
cs ${matrix.APP_NAME}
composer remove nextcloud/ocp --dev
composer i
- name: Install dependencies
run: |
cs ${matrix.APP_NAME}
composer require --dev 'nextcloud/ocp:${{ matrix.ocp-version }}' --ignore-platform-reqs --with-dependencies
- name: Run coding standards check
run: |
cs ${matrix.APP_NAME}
composer run psalm
summary:
runs-on: ubuntu-latest-low
needs: static-analysis

if: always()

name: static-psalm-analysis-summary

steps:
- name: Summary status
run: if ${{ needs.static-analysis.result != 'success' }}; then exit 1; fi
12 changes: 12 additions & 0 deletions socialsharing_diaspora/.php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);

require_once './vendor/autoload.php';

use Nextcloud\CodingStandard\Config;

$config = new Config();
$config
->getFinder()
->in(__DIR__ . '/lib');
return $config;
2 changes: 1 addition & 1 deletion socialsharing_diaspora/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<screenshot>https://raw.githubusercontent.com/nextcloud/socialsharing/master/socialsharing_diaspora/screenshots/preview.png</screenshot>
<namespace>SocialSharingDiaspora</namespace>
<dependencies>
<nextcloud min-version="26" max-version="30" />
<nextcloud min-version="28" max-version="30" />
</dependencies>
<bugs>https://github.com/nextcloud/socialsharing</bugs>
<website>https://github.com/nextcloud/socialsharing</website>
Expand Down
24 changes: 24 additions & 0 deletions socialsharing_diaspora/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"require": {
"php": ">=8.0"
},
"scripts": {
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l",
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar --no-cache",
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"psalm:update-baseline:force": "psalm.phar --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"nextcloud/coding-standard": "^1",
"psalm/phar": "^5.26",
"nextcloud/ocp": "dev-master"
},
"config": {
"platform": {
"php": "8.0"
}
}
}
Loading

0 comments on commit 0881144

Please sign in to comment.