From e380894ee033f16748ec9eb708746200f3ac5cdf Mon Sep 17 00:00:00 2001 From: PedroTroller Date: Fri, 23 Jun 2023 11:07:35 +0200 Subject: [PATCH] ci: try to split main repository into sub repositories --- .gitconfig | 2 + .github/workflows/build.yaml | 82 ----------------------------------- .github/workflows/split.yaml | 84 ++++++++++++++++++++++++++++++++++++ src/Core/FileToPdf.php | 1 + 4 files changed, 87 insertions(+), 82 deletions(-) create mode 100644 .gitconfig delete mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/split.yaml diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 00000000..57623b3b --- /dev/null +++ b/.gitconfig @@ -0,0 +1,2 @@ +[safe] + directory = "*" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index fae48d5a..00000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: Build - -on: - pull_request: ~ - push: ~ - -jobs: - check: - runs-on: ubuntu-20.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - - name: Validate composer.json - run: composer validate --strict --no-check-lock - cs-fixer: - runs-on: ubuntu-20.04 - name: PHP-CS-Fixer - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '7.3' - - run: composer install --prefer-dist --no-interaction --no-progress --ansi - - run: vendor/bin/php-cs-fixer fix --diff --dry-run --verbose - tests: - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - include: - - description: 'Symfony 6.3 DEV' - php: '8.2' - symfony: '6.3.*@dev' - - description: 'Symfony 6.2' - php: '8.2' - symfony: '6.2.*' - - description: 'Symfony 6.0' - php: '8.1' - symfony: '6.0.*' - - description: 'Symfony 5.0' - php: '7.3' - symfony: '5.0.*' - - description: 'Symfony 4.4' - php: '7.1' - symfony: '4.3.*@dev' - - description: 'Symfony 3.4' - php: '7.3' - symfony: '3.4.*' - - description: 'Beta deps' - php: '7.2' - beta: true - name: PHP ${{ matrix.php }} tests (${{ matrix.description }}) - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Cache - uses: actions/cache@v3 - with: - path: ~/.composer/cache/files - key: composer-${{ matrix.php }}-${{ matrix.symfony }}-${{ matrix.composer_option }} - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - - run: | - sed -ri 's/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json; - if: matrix.symfony - - run: | - composer config minimum-stability dev - composer config prefer-stable true - if: matrix.beta - - name: remove cs-fixer for Symfony 6 - if: contains(matrix.symfony, '6.3.*@dev') - run: | - composer remove --dev friendsofphp/php-cs-fixer pedrotroller/php-cs-custom-fixer --no-update - - run: composer update --prefer-dist --no-interaction --no-progress --ansi ${{ matrix.composer_option }} - - run: vendor/bin/phpunit - - run: vendor/bin/phpstan analyse --ansi --no-progress diff --git a/.github/workflows/split.yaml b/.github/workflows/split.yaml new file mode 100644 index 00000000..89d108b5 --- /dev/null +++ b/.github/workflows/split.yaml @@ -0,0 +1,84 @@ +--- +name: 'Packages Split' + +on: + push: + branches: + - v2-unstable-repository-split + tags: + - '*' + +env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + +jobs: + sub_packages: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + package: + - path: 'src/Core' + remote: 'knplabs/snappy-core' + - path: 'src/Backend/WkHtmlToPdf' + remote: 'knplabs/snappy-wkhtmltopdf' + steps: + - uses: actions/checkout@v2 + with: + path: ./monolyth + - run: mkdir ./readonly + - name: git clone + run: | + cd ./readonly + git clone -- https://${{ secrets.ACCESS_TOKEN }}@github.com/${{ matrix.package.remote }} . + git checkout -b main || git branch main + - name: git fetch + run: | + cd ./readonly + git fetch + - run: cp --verbose -ra ./monolyth/${{ matrix.package.path }}/* ./readonly + - run: ls -la ./readonly + - name: git status + run: | + cd ./readonly + git status + - name: git add + run: | + cd ./readonly + git add . + - id: commit_message + name: commit_message + run: | + echo "COMMIT_MESSAGE=$(cd ./monolyth; git show -s --format=%B ${GITHUB_SHA})" + export "COMMIT_MESSAGE=$(cd ./monolyth; git show -s --format=%B ${GITHUB_SHA})" >> $GITHUB_OUTPUT + - name: git commit + run: | + cd ./readonly + git commit --message `${{ steps.commit_message.output.COMMIT_MESSAGE }}` + - name: git push + run: | + cd ./readonly + git push --quiet origin main + - if: "startsWith(github.ref, 'refs/tags/')" + name: git tag + run: | + cd ./readonly + git tag %s -m "${GITHUB_REF#refs/tags/}" + git push --quiet origin "${GITHUB_REF#refs/tags/}" +# - if: "!startsWith(github.ref, 'refs/tags/')" +# uses: "symplify/monorepo-split-github-action@2.1" +# with: +# package_directory: '${{ matrix.package.path }}' +# repository_organization: 'knplabs' +# repository_name: '${{ matrix.package.remote }}' +# user_name: "knpEdgar" +# user_email: "hello@knplabs.com" +# - if: "startsWith(github.ref, 'refs/tags/')" +# uses: "symplify/monorepo-split-github-action@2.1" +# with: +# tag: ${GITHUB_REF#refs/tags/} +# package_directory: '${{ matrix.package.path }}' +# repository_organization: 'knplabs' +# repository_name: '${{ matrix.package.remote }}' +# user_name: "knpEdgar" +# user_email: "hello@knplabs.com" diff --git a/src/Core/FileToPdf.php b/src/Core/FileToPdf.php index b252e0d5..fe6bd61d 100644 --- a/src/Core/FileToPdf.php +++ b/src/Core/FileToPdf.php @@ -8,5 +8,6 @@ interface FileToPdf { + public function generate(SplFileInfo $file, ArrayAccess|array $options = []): StreamInterface; }