Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/actions #28

Merged
merged 28 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Configuration for welcome - https://github.com/behaviorbot/welcome

# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome

# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
# Comment to be posted to on PRs from first time contributors in your repository
newPRWelcomeComment: >
Thanks for opening this pull request, a maintainer will get back to you shortly!
In the meantime, please check out the [contributing guidelines](../tree/master/CONTRIBUTING.md).
# Configuration for sentiment-bot - https://github.com/behaviorbot/sentiment-bot

# *Required* toxicity threshold between 0 and .99 with the higher numbers being the most toxic
# Anything higher than this threshold will be marked as toxic and commented on
sentimentBotToxicityThreshold: .7

# *Required* Comment to reply with
sentimentBotReplyComment: >
Please be respectful of other users. cc/ @rvalitov
3 changes: 2 additions & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ markComment: >
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false
closeComment: >
This issue was automatically closed due to inactivity.
70 changes: 56 additions & 14 deletions .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,38 @@ name: Codacy Security Scan

on:
push:
branches: ["master"]
branches: ["master", "main"]
pull_request:
# The branches below must be a subset of the branches above
branches: ["master"]
branches: ["master", "main"]

# Allows you to run this workflow manually from the Actions tab
# eslint-disable-next-line yml/no-empty-mapping-value
workflow_dispatch:

permissions:
contents: read

env:
NODE_VERSION: latest
PHP_VERSION: 8.3
PHPUNIT_VERSION: 11

jobs:
codacy-security-scan:
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
name: Codacy Security Scan
runs-on: ubuntu-latest
runs-on: ${{ vars.UBUNTU_VERSION }}
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v4

# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
uses: codacy/codacy-analysis-cli-action@v4.4.5
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
Expand All @@ -55,20 +60,57 @@ jobs:
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
codacy-analysis-cli:
name: Codacy Analysis CLI

codacy-coverage-reporter:
name: Codacy Coverage Reporter
runs-on: ${{ vars.UBUNTU_VERSION }}
if: github.event_name == 'push'
steps:
- name: Setup PHP ${{ env.PHP_VERSION }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, intl, xdebug, json, sockets
ini-values: max_execution_time=360
coverage: xdebug
tools: php-cs-fixer, phpunit:${{ env.PHPUNIT_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: PHP info
run: php -v

- name: Checkout code
uses: actions/checkout@main
uses: actions/checkout@v4

- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"

- name: Starting local web server
# bash shell is required for Windows, otherwise the background
# server does not start and work properly
shell: bash
run: npm run start-server &
- name: Wait for server to start up
run: npx wait-on --timeout 15000 http://127.0.0.1:3000
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
- name: Server warm up
run: sleep 5

- name: Test coverage
run: npm run coverage
- name: Codacy coverage reporter
uses: codacy/[email protected]
with:
verbose: true
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# or
# api-token: ${{ secrets.CODACY_API_TOKEN }}
upload: true
max-allowed-issues: 2147483647
coverage-reports: coverage/clover.xml
# or a comma-separated list for multiple reports
# coverage-reports: <PATH_TO_REPORT>, <PATH_TO_REPORT>
7 changes: 4 additions & 3 deletions .github/workflows/devskim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ name: DevSkim

on:
push:
branches: ["master"]
branches: ["master", "main"]
pull_request:
branches: ["master"]
branches: ["master", "main"]

# Allows you to run this workflow manually from the Actions tab
# eslint-disable-next-line yml/no-empty-mapping-value
workflow_dispatch:

jobs:
lint:
name: DevSkim
runs-on: ubuntu-latest
runs-on: ${{ vars.UBUNTU_VERSION }}
permissions:
actions: read
contents: read
Expand Down
45 changes: 40 additions & 5 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ name: SonarCloud analysis

on:
push:
branches: ["master"]
branches: ["master", "main"]
pull_request:
branches: ["master"]
branches: ["master", "main"]
types: [opened, synchronize, reopened]

# Allows you to run this workflow manually from the Actions tab
# eslint-disable-next-line yml/no-empty-mapping-value
workflow_dispatch:

Expand All @@ -19,28 +20,62 @@ permissions:

env:
NODE_VERSION: latest
PHP_VERSION: 8.3
PHPUNIT_VERSION: 11

jobs:
sonarqube:
name: SonarQube
runs-on: ${{ vars.UBUNTU_VERSION }}

steps:
- name: Setup PHP ${{ env.PHP_VERSION }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, intl, xdebug, json, sockets
ini-values: max_execution_time=360
coverage: xdebug
tools: php-cs-fixer, phpunit:${{ env.PHPUNIT_VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: PHP info
run: php -v

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# Disabling shallow clones is recommended for improving the relevancy of reporting
fetch-depth: 0

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@master
uses: actions/setup-node@v4.1.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"

- name: Starting local web server
# bash shell is required for Windows, otherwise the background
# server does not start and work properly
shell: bash
run: npm run start-server &
- name: Wait for server to start up
run: npx wait-on --timeout 15000 http://127.0.0.1:3000
Fixed Show fixed Hide fixed
Dismissed Show dismissed Hide dismissed
- name: Server warm up
run: sleep 5

- name: Test coverage
run: npm run coverage

- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v4
uses: SonarSource/[email protected]
with:
args: >
-Dsonar.verbose=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
17 changes: 4 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Tests

on:
push:
branches: ["master"]
branches: ["master", "main"]
pull_request:
branches: ["master"]
branches: ["master", "main"]

permissions:
contents: read
Expand Down Expand Up @@ -64,6 +64,8 @@ jobs:
restore-keys: |
${{ runner.os }}-php-

- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install dependencies
run: composer install --prefer-dist --no-progress

Expand Down Expand Up @@ -91,14 +93,3 @@ jobs:
- if: matrix.operating-system != 'windows-latest'
name: Run full test suite
run: npm run test

- if: github.actor != 'dependabot[bot]'
name: Codacy coverage reporter
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
# or
# api-token: ${{ secrets.CODACY_API_TOKEN }}
coverage-reports: ./coverage/clover.xml
# or a comma-separated list for multiple reports
# coverage-reports: <PATH_TO_REPORT>, <PATH_TO_REPORT>
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ node_modules/
*.phar
*.cache
coverage

91 changes: 91 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Contributing to Backlink Checker PHP

Thank you for considering contributing to this project!
To contribute, please follow these guidelines.

## 1. Fork the Repository and Create Your Branch

1. Fork the repository.
2. Create a new branch from `master` for your changes.

## 2. Adhere to Existing Style Conventions

Ensure your code adheres to the existing style conventions used in the project.
You can use the following command to check the style conventions:

```bash
npm run style
```

If you see any errors or warnings, please fix them before opening a pull request.

You can use the following command to fix the Markdown style issues:

```bash
npm run markdown:fix
```

To fix other style issues, you can use the following command:

```bash
npm run prettier:fix
```

If you modify the dependencies in `package.json` or `composer.json` or modify these files manually,
please keep the file sorted:

```bash
npm run sort
```

## 3. Run Tests to Ensure Changes Do Not Break Functionality

First run the tests for static PHP code analysis:

```bash
npm run php
```

If you see any errors or warnings, please fix them before opening a pull request.
Some errors or warnings can be fixed automatically using the following command:

```bash
npm run phpcs-fixer:fix
```

Then run the PHPUnit tests for the PHP code. First start the server:

```bash
npm run start-server
```

Then run the tests.
Be sure to keep the server running while running the tests.
You can run the tests using the following command in a new terminal:

```bash
npm run test
```

This command will run all the tests, including the static analysis checks.

## 4. Add New Tests for Your Changes if Applicable

* Add new tests for your changes if applicable.
* Ensure the tests cover all the possible scenarios and edge cases.
* The tests should be added to the `tests` directory.
* Sample data for the tests should be added to the `tests/data` directory.

## 5. Open a Pull Request with a Clear Description

Open a pull request with a clear description of your changes and the problem they solve.
If your pull request fixes an issue, please reference the issue in the pull request description.

## 6. Update the Documentation

If you add new features or modify existing features, please update the `README.md` file.

## 7. Resources

* [Using Pull Requests](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests)
* [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow)
Loading