Skip to content

Commit

Permalink
Merge pull request #5527 from nextcloud/chore/update_workflows_stable27
Browse files Browse the repository at this point in the history
[stable27] chore(ci): Update Github workflows
  • Loading branch information
mejo- committed Mar 20, 2024
2 parents ba5affb + 1a2ee8b commit 26aba9b
Show file tree
Hide file tree
Showing 24 changed files with 3,268 additions and 524 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/block-merge-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:

if: github.event.pull_request.draft == false

runs-on: ubuntu-latest
runs-on: ubuntu-latest-low

steps:
- name: Register text Git reference
- name: Register server reference to fallback to master branch
run: |
server_ref="$(if [ "${{ github.base_ref }}" = "main" ]; then echo -n "master"; else echo -n "${{ github.base_ref }}"; fi)"
echo "server_ref=$server_ref" >> $GITHUB_ENV
Expand Down
71 changes: 47 additions & 24 deletions .github/workflows/command-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,34 @@ jobs:
arg1: ${{ steps.command.outputs.arg1 }}
arg2: ${{ steps.command.outputs.arg2 }}
head_ref: ${{ steps.comment-branch.outputs.head_ref }}
base_ref: ${{ steps.comment-branch.outputs.base_ref }}

steps:
- name: Check actor permission
uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2
uses: skjnldsv/check-actor-permission@69e92a3c4711150929bca9fcf34448c5bf5526e7 # v2
with:
require: write

- name: Add reaction on start
uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
repository: ${{ github.event.repository.full_name }}
comment-id: ${{ github.event.comment.id }}
reactions: "+1"

- name: Parse command
uses: skjnldsv/parse-command-comment@7cef1df370a99dfd5bf896d50121390c96785db8 # v2
uses: skjnldsv/parse-command-comment@5c955203c52424151e6d0e58fb9de8a9f6a605a1 # v2
id: command

# Init path depending on which command is run
- name: Init path
id: git-path
run: |
if ${{ startsWith(steps.command.outputs.arg1, '/') }}; then
echo "path=${{ github.workspace }}${{steps.command.outputs.arg1}}" >> $GITHUB_OUTPUT
echo "path=${{steps.command.outputs.arg1}}" >> $GITHUB_OUTPUT
else
echo "path=${{ github.workspace }}${{steps.command.outputs.arg2}}" >> $GITHUB_OUTPUT
echo "path=${{steps.command.outputs.arg2}}" >> $GITHUB_OUTPUT
fi
- name: Init branch
Expand All @@ -53,8 +54,14 @@ jobs:
needs: init

steps:
- name: Restore cached git repository
uses: buildjet/cache@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
with:
path: .git
key: git-repo

- name: Checkout ${{ needs.init.outputs.head_ref }}
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
fetch-depth: 0
Expand All @@ -66,49 +73,65 @@ jobs:
git config --local user.name "nextcloud-command"
- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
id: package-engines-versions
with:
fallbackNode: '^16'
fallbackNpm: '^7'
fallbackNode: '^20'
fallbackNpm: '^10'

- name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v3
with:
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
cache: npm

- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"

- name: Rebase to ${{ needs.init.outputs.base_ref }}
if: ${{ contains(needs.init.outputs.arg1, 'rebase') }}
run: |
git fetch origin ${{ needs.init.outputs.base_ref }}:${{ needs.init.outputs.base_ref }}
git rebase origin/${{ needs.init.outputs.base_ref }}
- name: Install dependencies & build
env:
CYPRESS_INSTALL_BINARY: 0
PUPPETEER_SKIP_DOWNLOAD: true
run: |
npm ci
npm run build --if-present
- name: Commit and push default
if: ${{ needs.init.outputs.arg1 != 'fixup' && needs.init.outputs.arg1 != 'amend' }}
- name: Commit default
if: ${{ !contains(needs.init.outputs.arg1, 'fixup') && !contains(needs.init.outputs.arg1, 'amend') }}
run: |
git add ${{ needs.init.outputs.git_path }}
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
git commit --signoff -m 'chore(assets): Recompile assets'
git push origin ${{ needs.init.outputs.head_ref }}
- name: Commit and push fixup
if: ${{ needs.init.outputs.arg1 == 'fixup' }}
- name: Commit fixup
if: ${{ contains(needs.init.outputs.arg1, 'fixup') }}
run: |
git add ${{ needs.init.outputs.git_path }}
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
git commit --fixup=HEAD --signoff
git push origin ${{ needs.init.outputs.head_ref }}
- name: Commit and push amend
if: ${{ needs.init.outputs.arg1 == 'amend' }}
- name: Commit amend
if: ${{ contains(needs.init.outputs.arg1, 'amend') }}
run: |
git add ${{ needs.init.outputs.git_path }}
git add ${{ github.workspace }}${{ needs.init.outputs.git_path }}
git commit --amend --no-edit --signoff
git push --force origin ${{ needs.init.outputs.head_ref }}
# Remove any [skip ci] from the amended commit
git commit --amend -m "$(git log -1 --format='%B' | sed '/\[skip ci\]/d')"
- name: Push normally
if: ${{ !contains(needs.init.outputs.arg1, 'rebase') && !contains(needs.init.outputs.arg1, 'amend') }}
run: git push origin ${{ needs.init.outputs.head_ref }}

- name: Force push
if: ${{ contains(needs.init.outputs.arg1, 'rebase') || contains(needs.init.outputs.arg1, 'amend') }}
run: git push --force origin ${{ needs.init.outputs.head_ref }}

- name: Add reaction on failure
uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
if: failure()
with:
token: ${{ secrets.COMMAND_BOT_PAT }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cypress-component.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
id: versions
with:
fallbackNode: "^20"
fallbackNpm: "^9"
fallbackNpm: "^10"

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

Expand All @@ -40,7 +40,7 @@ jobs:
npm ci
- name: Cypress component tests
uses: cypress-io/github-action@ebe8b24c4428922d0f793a5c4c96853a633180e3 # v6.6.0
uses: cypress-io/github-action@1b70233146622b69e789ccdd4f9452adc638d25a # v6.6.1
with:
component: true
env:
Expand Down
69 changes: 27 additions & 42 deletions .github/workflows/cypress.yml → .github/workflows/cypress-e2e.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
name: Cypress

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

concurrency:
group: ${{ github.head_ref || github.run_id }}
group: cypress-${{ github.head_ref || github.run_id }}
cancel-in-progress: ${{ !github.head_ref }}

env:
APP_NAME: text
# Adjust APP_NAME if your repository name is different
APP_NAME: ${{ github.event.repository.name }}
CYPRESS_baseUrl: http://localhost:8081/index.php

jobs:
Expand All @@ -23,7 +18,6 @@ jobs:
nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
npmVersion: ${{ steps.versions.outputs.npmVersion }}
strategy:
fail-fast: false
matrix:
server-versions: ['stable27']

Expand Down Expand Up @@ -52,26 +46,26 @@ jobs:
id: versions
with:
fallbackNode: "^20"
fallbackNpm: "^9"
fallbackNpm: "^10"
path: apps/${{ env.APP_NAME }}

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: 'npm'
node-version: ${{ steps.versions.outputs.nodeVersion }}

- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"

- name: Install dependencies & build app
- name: Install node dependencies & build app
working-directory: apps/${{ env.APP_NAME }}
run: |
npm ci
TESTING=true npm run build --if-present
- name: Save context
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: buildjet/cache/save@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
with:
key: cypress-context-${{ github.run_id }}
path: ./
Expand All @@ -83,25 +77,10 @@ jobs:
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6, 7, 8]
php-versions: [ '8.1' ]
containers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
php-versions: ['8.1']
run-in-parallel:
- false # only for PRs: ${{ !!github.head_ref }}
exclude:
- run-in-parallel: false
containers: 2
- run-in-parallel: false
containers: 3
- run-in-parallel: false
containers: 4
- run-in-parallel: false
containers: 5
- run-in-parallel: false
containers: 6
- run-in-parallel: false
containers: 7
- run-in-parallel: false
containers: 8

name: runner ${{ matrix.containers }}

Expand All @@ -118,14 +97,14 @@ jobs:

steps:
- name: Restore context
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
uses: buildjet/cache/restore@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
with:
fail-on-cache-miss: true
key: cypress-context-${{ github.run_id }}
path: ./

- name: Set up node ${{ needs.init.outputs.nodeVersion }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
cache: 'npm'
node-version: ${{ needs.init.outputs.nodeVersion }}
Expand Down Expand Up @@ -158,11 +137,14 @@ jobs:
php occ app:enable viewer
php occ app:enable text
php occ app:list
php occ background:cron
php occ config:system:set session_keepalive --value=false --type=boolean
curl -v http://localhost:8081/index.php/login
cat data/nextcloud.log
- name: Cypress run
uses: cypress-io/github-action@v4
- name: Run E2E cypress tests
# Starting with v5.4.0, tons of "tar: ... Cannot mkdir: Permission denied" errors
uses: cypress-io/github-action@4d475873e011991664253f34700acfc3acdc46a3 # v5.3.0
with:
record: '${{ !!matrix.run-in-parallel }}' # only on pull requests
parallel: '${{ !!matrix.run-in-parallel }}' # only on pull requests
Expand All @@ -176,27 +158,30 @@ jobs:
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
npm_package_name: ${{ env.APP_NAME }}
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}


- name: Upload test failure screenshots
uses: actions/upload-artifact@v2
- name: Upload snapshots
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: failure()
with:
name: Upload screenshots
name: snapshots_${{ matrix.containers }}
path: |
apps/${{ env.APP_NAME }}/cypress/screenshots/
apps/${{ env.APP_NAME }}/cypress/snapshots/
retention-days: 5

- name: Upload nextcloud logs
uses: actions/upload-artifact@v2
- name: Upload NC logs
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
if: failure()
with:
name: Upload nextcloud log
name: nc_logs_${{ matrix.containers }}.log
path: data/nextcloud.log
retention-days: 5

summary:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-low
needs: [init, cypress]

if: always()
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dependabot-approve-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ concurrency:

jobs:
auto-approve-merge:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]' || github.actor == 'renovate[bot]'
runs-on: ubuntu-latest-low
permissions:
# for hmarr/auto-approve-action to approve PRs
pull-requests: write
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ jobs:

name: node
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3

- name: Read package.json node and npm engines version
uses: skjnldsv/read-package-engines-version-actions@v1.2
uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2
id: versions
with:
fallbackNode: '^16'
fallbackNpm: '^7'
fallbackNode: '^20'
fallbackNpm: '^9'

- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
uses: actions/setup-node@v3
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
with:
node-version: ${{ steps.versions.outputs.nodeVersion }}

Expand Down
Loading

0 comments on commit 26aba9b

Please sign in to comment.