Skip to content

Commit 7bababe

Browse files
committed
chore: add permissions to caller workflow for reusable CI
1 parent cc89b5c commit 7bababe

1 file changed

Lines changed: 5 additions & 209 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -3,219 +3,15 @@ on:
33
branches:
44
- "main"
55
pull_request:
6-
# schedule:
7-
# - cron: '24 10 * * 4'
86

97
name: "CI"
108

119
permissions:
1210
contents: read
13-
14-
env:
15-
PHP_VERSION: "8.3"
11+
actions: read
12+
security-events: write
1613

1714
jobs:
18-
qa:
19-
name: "QA (lint + static analysis)"
20-
if: "!startsWith(github.event.head_commit.message, 'chore(release)')"
21-
runs-on: "ubuntu-latest"
22-
steps:
23-
- name: "Checkout"
24-
uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
25-
26-
- name: "Install PHP"
27-
uses: "shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f" # 2.37.0
28-
with:
29-
coverage: "none"
30-
php-version: "${{ env.PHP_VERSION }}"
31-
32-
- name: "Validate composer.json and composer.lock"
33-
if: "github.actor != 'renovate[bot]' || contains(github.head_ref, 'lock-file-maintenance')"
34-
run: "composer validate --ansi --strict"
35-
36-
- name: "Determine composer cache directory"
37-
uses: "ergebnis/.github/actions/composer/determine-cache-directory@9785f99b3546d64df9cb331449e7fcdc41885d25" # 1.11.0
38-
39-
- name: "Cache dependencies installed with composer"
40-
uses: "actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7" # v5.0.4
41-
with:
42-
path: "${{ env.COMPOSER_CACHE_DIR }}"
43-
key: "php-${{ env.PHP_VERSION }}-composer-locked-${{ hashFiles('composer.lock') }}"
44-
restore-keys: |
45-
php-${{ env.PHP_VERSION }}-composer-locked-${{ github.ref_name }}
46-
php-${{ env.PHP_VERSION }}-composer-locked-
47-
php-${{ env.PHP_VERSION }}-composer-main
48-
49-
- name: "Install locked dependencies with composer"
50-
uses: "ergebnis/.github/actions/composer/install@9785f99b3546d64df9cb331449e7fcdc41885d25" # 1.11.0
51-
with:
52-
dependencies: "${{ (github.actor == 'renovate[bot]' && !contains(github.head_ref, 'lock-file-maintenance')) && 'highest' || 'locked' }}"
53-
54-
- name: "Check coding style"
55-
run: "vendor/bin/codecept build"
56-
57-
- name: "Check coding style"
58-
run: "composer cs:check"
59-
60-
- name: "Run static analysis"
61-
run: "composer stan"
62-
63-
# codacy:
64-
# name: "Codacy Security Scan"
65-
# if: "!startsWith(github.event.head_commit.message, 'chore(release)')"
66-
# runs-on: "ubuntu-latest"
67-
# permissions:
68-
# contents: read
69-
# security-events: write
70-
# actions: read
71-
# steps:
72-
# - name: Checkout code
73-
# uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
74-
#
75-
# - name: Run Codacy Analysis CLI
76-
# uses: codacy/codacy-analysis-cli-action@30783d03e758713bb5ed7b79292cfb14b9dd9a4a
77-
# with:
78-
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
79-
# verbose: false
80-
# output: results.sarif
81-
# format: sarif
82-
# upload: true
83-
# skip-uncommitted-files-check: true
84-
# gh-code-scanning-compat: true
85-
# max-allowed-issues: 2147483647
86-
87-
tests:
88-
name: "Run codeception tests"
89-
needs: [ qa ]
90-
runs-on: "ubuntu-latest"
91-
strategy:
92-
matrix:
93-
include:
94-
- { php-version: 8.3, dependencies: locked, coverage: pcov, with_coverage: false, allow-fail: false }
95-
96-
- { php-version: 8.4, dependencies: highest, coverage: pcov, with_coverage: false, allow-fail: true }
97-
- { php-version: 8.5, dependencies: highest, coverage: pcov, with_coverage: false, allow-fail: true }
98-
steps:
99-
- name: "Checkout"
100-
uses: "actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd" # v6.0.2
101-
102-
- name: "Install PHP"
103-
uses: "shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f" # 2.37.0
104-
with:
105-
coverage: "${{ matrix.coverage }}"
106-
ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
107-
php-version: "${{ matrix.php-version }}"
108-
109-
- name: "Set up problem matchers for PHP"
110-
run: "echo \"::add-matcher::${{ runner.tool_cache }}/php.json\""
111-
112-
- name: "Set up problem matchers for phpunit/phpunit"
113-
run: "echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\""
114-
115-
- name: "Validate composer.json and composer.lock"
116-
if: "github.actor != 'renovate[bot]' || contains(github.head_ref, 'lock-file-maintenance')"
117-
run: "composer validate --ansi --strict"
118-
119-
- name: "Determine composer cache directory"
120-
uses: "ergebnis/.github/actions/composer/determine-cache-directory@9785f99b3546d64df9cb331449e7fcdc41885d25" # 1.11.0
121-
122-
- name: "Cache dependencies installed with composer"
123-
uses: "actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7" # v5.0.4
124-
with:
125-
path: "${{ env.COMPOSER_CACHE_DIR }}"
126-
key: "php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ hashFiles('composer.lock') }}"
127-
restore-keys: |
128-
php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-${{ github.ref_name }}
129-
php-${{ matrix.php-version }}-composer-${{ matrix.dependencies }}-
130-
php-${{ matrix.php-version }}-composer-main
131-
132-
- name: "Install ${{ matrix.dependencies }} dependencies with composer"
133-
uses: "ergebnis/.github/actions/composer/install@9785f99b3546d64df9cb331449e7fcdc41885d25" # 1.11.0
134-
with:
135-
dependencies: "${{ (github.actor == 'renovate[bot]' && !contains(github.head_ref, 'lock-file-maintenance') && matrix.dependencies == 'locked') && 'highest' || matrix.dependencies }}"
136-
137-
- name: "Run Tests (coverage)"
138-
if: matrix.with_coverage == true
139-
run: |
140-
vendor/bin/codecept build
141-
vendor/bin/codecept run --coverage --coverage-xml=coverage.xml --xml --report
142-
143-
- name: "Run Tests"
144-
if: matrix.with_coverage != true
145-
run: |
146-
vendor/bin/codecept build
147-
vendor/bin/codecept run --xml --report
148-
149-
- name: "Upload coverage artifact"
150-
if: matrix.with_coverage == true
151-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
152-
with:
153-
name: code-coverage-results
154-
path: tests/_output/
155-
retention-days: 5
156-
157-
# - name: "Upload Coverage coverage"
158-
# if: matrix.with_coverage == true
159-
# run: |
160-
# export CODACY_PROJECT_TOKEN=${{ secrets.CODACY_PROJECT_TOKEN }}
161-
# bash <(curl -Ls https://coverage.codacy.com/get.sh) report -r ./build/logs/coverage.xml
162-
#
163-
# - name: Upload test results to Codecov
164-
# if: ${{ !cancelled() && matrix.with_coverage == true }}
165-
# uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
166-
# with:
167-
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
168-
# files: ./build/logs/report.xml
169-
# flags: unittests # optional
170-
# report_type: test_results
171-
# fail_ci_if_error: "${{ matrix.with_coverage }}" # optional (default = false)
172-
# verbose: false # optional (default = false)
173-
# - name: Upload coverage to Codecov
174-
# if: ${{ !cancelled() && matrix.with_coverage == true }}
175-
# uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5
176-
# with:
177-
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
178-
# files: ./build/logs/coverage.xml
179-
# flags: unittests # optional
180-
# fail_ci_if_error: "${{ matrix.with_coverage }}" # optional (default = false)
181-
# verbose: false # optional (default = false)
182-
183-
release:
184-
name: "Release"
185-
needs:
186-
- tests
187-
# - codacy
188-
if: "github.event_name == 'push' && github.ref == 'refs/heads/main' && !startsWith(github.event.head_commit.message, 'chore(release)')"
189-
runs-on: "ubuntu-latest"
190-
permissions:
191-
actions: read
192-
contents: read
193-
steps:
194-
- name: Generate Token
195-
id: generate_token
196-
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3
197-
with:
198-
app-id: ${{ secrets.BOT_APP_ID }}
199-
private-key: ${{ secrets.BOT_APP_PRIVATE_KEY }}
200-
201-
- name: Checkout
202-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
203-
with:
204-
fetch-depth: 0
205-
token: ${{ steps.generate_token.outputs.token }}
206-
207-
- name: Semantic Release
208-
uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0
209-
with:
210-
tag_format: ${version}
211-
branches: |
212-
['main']
213-
extra_plugins: |
214-
@semantic-release/commit-analyzer
215-
@semantic-release/release-notes-generator
216-
@semantic-release/github
217-
@semantic-release/changelog
218-
@semantic-release/git
219-
conventional-changelog-conventionalcommits
220-
env:
221-
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
15+
ci:
16+
uses: "WebProject-xyz/.github/.github/workflows/ci.yml@main"
17+
secrets: inherit

0 commit comments

Comments
 (0)