From ff7272477e8c42c2021033aac89b446d34af3df1 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 09:38:06 +0200 Subject: [PATCH 01/13] feat: attempt to create and test action --- .github/workflows/cohesion.yml | 26 +++++++++++++++++ action.yml | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 .github/workflows/cohesion.yml create mode 100644 action.yml diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml new file mode 100644 index 0000000..042738b --- /dev/null +++ b/.github/workflows/cohesion.yml @@ -0,0 +1,26 @@ +name: 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 + + - name: Swift Package Resolve + run: swift package resolve + + - uses: arthurpalves/coherent-swift@v0.1.0 + with: + source: Sources/ + minimum_threshold: 60 + ignore_output_result: true + report_format: plain + diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..888f08e --- /dev/null +++ b/action.yml @@ -0,0 +1,52 @@ +name: 'coherent-swift' +description: 'Measures cohesion in your Swift codebase' +author: 'Arthur Alves ' + +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" > coherent-swift.yml + echo -e "minimum_threshold: ${{ inputs.minimum_threshold }}\n" >> coherent-swift.yml + echo -e "reports_folder: ${{ inputs.reports_folder }}\n" >> coherent-swift.yml + echo -e "ignore_output_result: ${{ inputs.ignore_output_result }}\n" >> coherent-swift.yml + echo -e "report_format: ${{ inputs.report_format }}\n" >> coherent-swift.yml + + - name: Measure cohesion on changes only + if: inputs.only_changes == 'true' + shell: bash + run: | + swift run ${{ github.action_path }}/coherent-swift report -d -s coherent-swift.yml + + - name: Measure cohesion + if: inputs.only_changes != 'true' + shell: bash + run: | + swift run ${{ github.action_path }}/coherent-swift report -s coherent-swift.yml From 7d37cf46a41fd39a2c541702c1ca4d6b53dcbc06 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 09:44:51 +0200 Subject: [PATCH 02/13] action: specify action version 0.5.3 --- .github/workflows/cohesion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml index 042738b..533f0cd 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/cohesion.yml @@ -17,7 +17,7 @@ jobs: - name: Swift Package Resolve run: swift package resolve - - uses: arthurpalves/coherent-swift@v0.1.0 + - uses: arthurpalves/coherent-swift@0.5.3 with: source: Sources/ minimum_threshold: 60 From 6dbda3df536b38e35ced543fd5c42ff4655b1728 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 09:46:49 +0200 Subject: [PATCH 03/13] chore: change name of action --- .github/workflows/cohesion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml index 533f0cd..7b56af3 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/cohesion.yml @@ -1,4 +1,4 @@ -name: action +name: test_action on: push: From 49902c073c1ea621b0aa17da8eb9544194dee588 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 09:55:17 +0200 Subject: [PATCH 04/13] ci: correct yaml file --- .github/workflows/cohesion.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml index 7b56af3..65386c3 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/cohesion.yml @@ -1,4 +1,4 @@ -name: test_action +name: action on: push: @@ -17,9 +17,9 @@ jobs: - name: Swift Package Resolve run: swift package resolve - - uses: arthurpalves/coherent-swift@0.5.3 + - uses: arthurpalves/coherent-swift@0.5.3 with: - source: Sources/ + source: Sources minimum_threshold: 60 ignore_output_result: true report_format: plain From 9a2b987169e1d0df220d328682b783a00fcb4672 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 09:58:46 +0200 Subject: [PATCH 05/13] ref: adjust conditional run --- action.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 888f08e..9cf985a 100644 --- a/action.yml +++ b/action.yml @@ -39,14 +39,11 @@ runs: echo -e "ignore_output_result: ${{ inputs.ignore_output_result }}\n" >> coherent-swift.yml echo -e "report_format: ${{ inputs.report_format }}\n" >> coherent-swift.yml - - name: Measure cohesion on changes only - if: inputs.only_changes == 'true' + - name: Measure cohesion changes only shell: bash run: | - swift run ${{ github.action_path }}/coherent-swift report -d -s coherent-swift.yml - - - name: Measure cohesion - if: inputs.only_changes != 'true' - shell: bash - run: | - swift run ${{ github.action_path }}/coherent-swift report -s coherent-swift.yml + if [ ${{ inputs.only_changes }} == 'true' ]; then + swift run ${{ github.action_path }}/coherent-swift report -d -s coherent-swift.yml + else + swift run ${{ github.action_path }}/coherent-swift report -s coherent-swift.yml + fi From 9ee4d53a44c938a5702e902911995ca2e8b65729 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:08:10 +0200 Subject: [PATCH 06/13] ci: test action measuring overall cohesion --- action.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 9cf985a..e4f5948 100644 --- a/action.yml +++ b/action.yml @@ -39,11 +39,6 @@ runs: echo -e "ignore_output_result: ${{ inputs.ignore_output_result }}\n" >> coherent-swift.yml echo -e "report_format: ${{ inputs.report_format }}\n" >> coherent-swift.yml - - name: Measure cohesion changes only - shell: bash + - name: Measure cohesion run: | - if [ ${{ inputs.only_changes }} == 'true' ]; then - swift run ${{ github.action_path }}/coherent-swift report -d -s coherent-swift.yml - else - swift run ${{ github.action_path }}/coherent-swift report -s coherent-swift.yml - fi + swift run ${{ github.action_path }}/coherent-swift report -s coherent-swift.yml From bbf70f6aca7838d5f72423d37eb09e2393a18430 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:17:55 +0200 Subject: [PATCH 07/13] ci: bump artefact version --- .github/workflows/cohesion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml index 65386c3..a6301ba 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/cohesion.yml @@ -17,7 +17,7 @@ jobs: - name: Swift Package Resolve run: swift package resolve - - uses: arthurpalves/coherent-swift@0.5.3 + - uses: arthurpalves/coherent-swift@0.5.4 with: source: Sources minimum_threshold: 60 From 07e6db68db32e9342ee0e42f1c7106afdd24d176 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:19:58 +0200 Subject: [PATCH 08/13] ci: specify shell --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index e4f5948..ee2c677 100644 --- a/action.yml +++ b/action.yml @@ -40,5 +40,6 @@ runs: echo -e "report_format: ${{ inputs.report_format }}\n" >> coherent-swift.yml - name: Measure cohesion + shell: bash run: | swift run ${{ github.action_path }}/coherent-swift report -s coherent-swift.yml From 81cf4311de022ec9fe81c947c699f58fb11535b2 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:23:57 +0200 Subject: [PATCH 09/13] ci: bump up version --- .github/workflows/cohesion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml index a6301ba..f861105 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/cohesion.yml @@ -17,7 +17,7 @@ jobs: - name: Swift Package Resolve run: swift package resolve - - uses: arthurpalves/coherent-swift@0.5.4 + - uses: arthurpalves/coherent-swift@0.5.4.4 with: source: Sources minimum_threshold: 60 From 2caf9d37a05bfe76754dfd57d57c741f203e714a Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:26:51 +0200 Subject: [PATCH 10/13] ci: bump up version --- .github/workflows/cohesion.yml | 2 +- action.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml index f861105..1773d38 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/cohesion.yml @@ -17,7 +17,7 @@ jobs: - name: Swift Package Resolve run: swift package resolve - - uses: arthurpalves/coherent-swift@0.5.4.4 + - uses: arthurpalves/coherent-swift@0.5.4.5 with: source: Sources minimum_threshold: 60 diff --git a/action.yml b/action.yml index ee2c677..dd39437 100644 --- a/action.yml +++ b/action.yml @@ -42,4 +42,5 @@ runs: - name: Measure cohesion shell: bash run: | - swift run ${{ github.action_path }}/coherent-swift report -s coherent-swift.yml + cd ${{ github.action_path }} + swift run coherent-swift report -s coherent-swift.yml From 562b37516d04e5b85622c30cd5c5bc29894b184c Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:32:05 +0200 Subject: [PATCH 11/13] ci: add back conditional measure for only changed files --- .github/workflows/cohesion.yml | 2 +- action.yml | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/cohesion.yml index 1773d38..b8581b3 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/cohesion.yml @@ -17,7 +17,7 @@ jobs: - name: Swift Package Resolve run: swift package resolve - - uses: arthurpalves/coherent-swift@0.5.4.5 + - uses: arthurpalves/coherent-swift@0.5.4.6 with: source: Sources minimum_threshold: 60 diff --git a/action.yml b/action.yml index dd39437..9435697 100644 --- a/action.yml +++ b/action.yml @@ -43,4 +43,8 @@ runs: shell: bash run: | cd ${{ github.action_path }} - swift run coherent-swift report -s coherent-swift.yml + 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 From 0504a7c4976505add0948ffd21656dbeabc5bdce Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:41:38 +0200 Subject: [PATCH 12/13] ci: bump up version --- .../workflows/{cohesion.yml => test_action.yml} | 8 +++----- action.yml | 16 ++++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) rename .github/workflows/{cohesion.yml => test_action.yml} (73%) diff --git a/.github/workflows/cohesion.yml b/.github/workflows/test_action.yml similarity index 73% rename from .github/workflows/cohesion.yml rename to .github/workflows/test_action.yml index b8581b3..12088d1 100644 --- a/.github/workflows/cohesion.yml +++ b/.github/workflows/test_action.yml @@ -1,4 +1,4 @@ -name: action +name: test_action on: push: @@ -14,13 +14,11 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Swift Package Resolve - run: swift package resolve - - - uses: arthurpalves/coherent-swift@0.5.4.6 + - uses: arthurpalves/coherent-swift@0.5.4.7 with: source: Sources minimum_threshold: 60 ignore_output_result: true + only_changes: true report_format: plain diff --git a/action.yml b/action.yml index 9435697..d3ba32d 100644 --- a/action.yml +++ b/action.yml @@ -33,18 +33,18 @@ runs: - name: Prepare spec shell: bash run: | - echo -e "source: ${{ inputs.source }}\n" > coherent-swift.yml - echo -e "minimum_threshold: ${{ inputs.minimum_threshold }}\n" >> coherent-swift.yml - echo -e "reports_folder: ${{ inputs.reports_folder }}\n" >> coherent-swift.yml - echo -e "ignore_output_result: ${{ inputs.ignore_output_result }}\n" >> coherent-swift.yml - echo -e "report_format: ${{ inputs.report_format }}\n" >> coherent-swift.yml + 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 + 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 + swift run coherent-swift report -s _coherent-swift.yml fi From cecbf7628402bbddb64ecd631f8286772833e5c7 Mon Sep 17 00:00:00 2001 From: Arthur Alves Date: Wed, 30 Sep 2020 10:54:05 +0200 Subject: [PATCH 13/13] feat: ability to run coherent-swift directly from Github Action --- .github/workflows/test_action.yml | 4 ++-- action.yml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_action.yml b/.github/workflows/test_action.yml index 12088d1..6cd439b 100644 --- a/.github/workflows/test_action.yml +++ b/.github/workflows/test_action.yml @@ -14,9 +14,9 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: arthurpalves/coherent-swift@0.5.4.7 + - uses: arthurpalves/coherent-swift@0.5.5 with: - source: Sources + source: Sources/ minimum_threshold: 60 ignore_output_result: true only_changes: true diff --git a/action.yml b/action.yml index d3ba32d..5fab4d7 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,9 @@ name: 'coherent-swift' description: 'Measures cohesion in your Swift codebase' author: 'Arthur Alves ' +branding: + icon: "code" + color: "green" inputs: source: