Skip to content

Commit

Permalink
Debug 18
Browse files Browse the repository at this point in the history
  • Loading branch information
fabasoad committed Jan 3, 2025
1 parent e39ff5e commit 60c769c
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 64 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
include:
- provider: cloudmersive
api-key: CLOUDMERSIVE_API_KEY
threshold: 0.32
threshold: 0.45
- provider: picpurify
api-key: PICPURIFY_API_KEY
threshold: 0.97
threshold: 0.95
- provider: sightengine
api-user: SIGHTENGINE_API_USER
api-key: SIGHTENGINE_API_SECRET
threshold: 0.8
threshold: 0.85
steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v4
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ on: # yamllint disable-line rule:truthy
- main

jobs:
js-lint:
name: JS Lint
uses: fabasoad/reusable-workflows/.github/workflows/wf-js-lint.yml@main
pre-commit:
name: Pre-commit
uses: fabasoad/reusable-workflows/.github/workflows/wf-pre-commit.yml@main
with:
skip-hooks: "audit, build, lint, test"
19 changes: 0 additions & 19 deletions .github/workflows/unit-tests.yml

This file was deleted.

Binary file removed 91cDPlxcRiL._SL1500_.jpg
Binary file not shown.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ use them to create an issue and fill all required fields.

## Use a consistent coding style

Please follow all the rules from [this](https://github.com/excelmicro/typescript)
great guide provided by [excelmicro](https://github.com/excelmicro) for coding style.
Please follow all the rules from [this](https://google.github.io/styleguide/shellguide.html)
great guide provided by Google for coding style.

## License

Expand Down
69 changes: 35 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ by chosen provider.

## Contents

<!-- prettier-ignore-start -->
<!-- TOC -->
* [NSFW detection action](#nsfw-detection-action)
* [Contents](#contents)
* [Providers](#providers)
* [Cloudmersive](#cloudmersive)
* [PicPurify](#picpurify)
* [SightEngine](#sightengine)
* [Supported OS](#supported-os)
* [Prerequisites](#prerequisites)
* [Inputs](#inputs)
* [Example usage](#example-usage)
* [Workflow configuration](#workflow-configuration)
* [Result](#result)
* [Outputs](#outputs)
<!-- TOC -->
<!-- prettier-ignore-end -->

## Providers

Expand All @@ -53,42 +55,41 @@ requires to provide 2 API identifiers, so please put them into `api-key` paramet
separated by comma. For example, `api-key` should be _123456,abcdef_ if your
`api_user` is _123456_ and `api_secret` is _abcdef_.

## Inputs
## Supported OS

<!-- prettier-ignore-start -->
| OS | |
|---------|--------------------|
| Windows | :white_check_mark: |
| Linux | :white_check_mark: |
| macOS | :white_check_mark: |
<!-- prettier-ignore-end -->

| Name | Required | Description | Default | Possible values |
|--------------|----------|-----------------------------------------------------------------------------------------------|----------------------------------|----------------------------------|
| github-token | Yes | GitHub token | | &lt;String&gt; |
| provider | Yes | Provider identifier | | &lt;String&gt; |
| api-key | Yes | API key that should be used for chosen `provider` | | &lt;String&gt; |
| threshold | Yes | Action will be failed in case NSFW detection value will be greater or equal to this parameter | | &lt;Float&gt; |
| type | No | Type of committed files separated by comma | `modified,added,renamed` | `modified,added,renamed` |
| extensions | No | List of file extensions separated by comma | `jpeg,jpg,png,gif,webp,tiff,bmp` | `jpeg,jpg,png,gif,webp,tiff,bmp` |
## Prerequisites

## Example usage
The following tools have to be installed for successful work of this GitHub Action:
[curl](https://curl.se), [awk](https://en.wikipedia.org/wiki/AWK).

### Workflow configuration
## Inputs

```yaml
name: Test

on: push

jobs:
nsfw-detection:
name: Verify files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: fabasoad/nsfw-detection-action@v3
with:
provider: picpurify
threshold: 0.9
type: modified,added,renamed
extensions: jpg,jpeg
github-token: ${{ github.token }}
api-key: ${{ secrets.PICPURIFY_API_KEY }}
- uses: fabasoad/nsfw-detection-action@v3
with:
# (Required) Provider identifier.
provider: "picpurify"
# (Required) API key required for the selected provider.
api-key: ${{ secrets.PICPURIFY_API_KEY }}
# (Required) The action will fail if the NSFW detection value is greater
# than or equal to this parameter.
threshold: "0.6"
# (Optional) Comma-separated list of file extensions for NSFW detection.
# Defaults to "jpeg,jpg,png,gif,webp,tiff,bmp".
extensions: "jpg,png,gif"
# (Optional) Comma-separated types of changes made during work on the branch.
# Defaults to "added,copied,modified,renamed".
types: "added,modified"
```
### Result
## Outputs
![Result](screenshot1.png)
None.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ runs:
INPUT_API_KEY: ${{ inputs.api-key }}
INPUT_THRESHOLD: ${{ inputs.threshold }}
run: |
# TODO: Not all files but based on types
${GITHUB_ACTION_PATH}/src/providers/${INPUT_PROVIDER}.sh \
"${{ steps.changed-files.outputs.all_changed_files }}" \
"${INPUT_API_KEY}" \
Expand Down
Binary file removed screenshot1.png
Binary file not shown.
2 changes: 1 addition & 1 deletion src/compare-with-threshold.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ compare_with_threshold() {
threshold="${2}"
file_path="${3}"

if awk -v t="${threshold}" -v s="${score}" 'BEGIN {exit !((t - s) < 0)}'; then
if awk -v t="${threshold}" -v s="${score}" 'BEGIN {exit !((t - s) <= 0)}'; then
log_error "NSFW content detected in ${file_path} with score ${score}."
exit 1
elif awk -v t="${threshold}" -v s="${score}" 'BEGIN {exit !((t - s) > 0.2)}'; then
Expand Down

0 comments on commit 60c769c

Please sign in to comment.