diff --git a/.github/workflows/test_action.yml b/.github/workflows/test_action.yml new file mode 100644 index 0000000..6cd439b --- /dev/null +++ b/.github/workflows/test_action.yml @@ -0,0 +1,24 @@ +name: test_action + +on: + push: + branches: [ action ] +env: + DEVELOPER_DIR: /Applications/Xcode_11.4.app/Contents/Developer + GITHUB_TOKEN: ${{ secrets.PAT }} + +jobs: + build: + runs-on: macos-latest + + steps: + - uses: actions/checkout@v2 + + - uses: arthurpalves/coherent-swift@0.5.5 + with: + source: Sources/ + minimum_threshold: 60 + ignore_output_result: true + only_changes: true + report_format: plain + diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..5fab4d7 --- /dev/null +++ b/action.yml @@ -0,0 +1,53 @@ +name: 'coherent-swift' +description: 'Measures cohesion in your Swift codebase' +author: 'Arthur Alves ' +branding: + icon: "code" + color: "green" + +inputs: + source: + description: 'Source folder to scan.' + required: true + minimum_threshold: + description: 'Overall cohesion will be validated against this minimum threshold.' + required: true + default: '80' + reports_folder: + description: 'The folder where your reports will be saved to.' + required: true + default: './coherent-swift-reports' + ignore_output_result: + description: 'If "true", measure in passive mode. Observe without enforcing changes' + required: true + default: 'false' + report_format: + description: 'Format of cohesion report. Available formats: json, plain' + required: true + default: 'json' + only_changes: + description: 'If "true", only measure cohesion on changed files.' + required: true + default: 'false' + +runs: + using: "composite" + steps: + - name: Prepare spec + shell: bash + run: | + echo -e "source: ${{ inputs.source }}\n" > ${{ github.action_path }}/_coherent-swift.yml + echo -e "minimum_threshold: ${{ inputs.minimum_threshold }}\n" >> ${{ github.action_path }}/_coherent-swift.yml + echo -e "reports_folder: ${{ inputs.reports_folder }}\n" >> ${{ github.action_path }}/_coherent-swift.yml + echo -e "ignore_output_result: ${{ inputs.ignore_output_result }}\n" >> ${{ github.action_path }}/_coherent-swift.yml + echo -e "report_format: ${{ inputs.report_format }}\n" >> ${{ github.action_path }}/_coherent-swift.yml + + - name: Measure cohesion + shell: bash + run: | + cd ${{ github.action_path }} + if [[ ${{ inputs.only_changes }} == 'true' ]]; then + swift run coherent-swift report -d -s _coherent-swift.yml + else + swift run coherent-swift report -s _coherent-swift.yml + fi