From 4bdf41c17d331e195fc1802ac53e697c1dfc31a6 Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 11:54:02 +1200 Subject: [PATCH 01/17] feat: hello world action code --- Dockerfile | 8 ++++++++ action.yml | 16 ++++++++++++++++ entrypoint.sh | 5 +++++ 3 files changed, 29 insertions(+) create mode 100644 Dockerfile create mode 100644 action.yml create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9761d19 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +# Container image that runs your code +FROM alpine:3.10 + +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY entrypoint.sh /entrypoint.sh + +# Code file to execute when the docker container starts up (`entrypoint.sh`) +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..0011139 --- /dev/null +++ b/action.yml @@ -0,0 +1,16 @@ +# action.yml +name: 'Hello World' +description: 'Greet someone and record the time' +inputs: + who-to-greet: # id of input + description: 'Who to greet' + required: true + default: 'World' +outputs: + time: # id of output + description: 'The time we greeted you' +runs: + using: 'docker' + image: 'Dockerfile' + args: + - ${{ inputs.who-to-greet }} \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..297a521 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/sh -l + +echo "Hello $1" +time=$(date) +echo "time=$time" >> $GITHUB_OUTPUT \ No newline at end of file From 0b695b048b5b305ccaa187a96e6175f3f0158e2b Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 12:52:48 +1200 Subject: [PATCH 02/17] fix: hopefully adding run permissions (already did in git but didn't work..) --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9761d19..e175586 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,5 +4,7 @@ FROM alpine:3.10 # Copies your code file from your action repository to the filesystem path `/` of the container COPY entrypoint.sh /entrypoint.sh +RUN chmod +x entrypoint.sh + # Code file to execute when the docker container starts up (`entrypoint.sh`) ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From cf71d6c9a8b7a1a346338e8b216dd37c99cbbfff Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 13:35:11 +1200 Subject: [PATCH 03/17] feat: started getting the action to have the right interface with stubbed data --- Gemfile.lock | 2 +- action.yml | 15 +++++++++++---- entrypoint.sh | 7 +++++-- lib/code_quality_score/lib.rb | 2 +- lib/code_quality_score/version.rb | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4673b05..f980f79 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - code_quality_score (0.1.7) + code_quality_score (0.1.8) flay (>= 2.13.0) flog (>= 4.6.5) reek (>= 6.1.1) diff --git a/action.yml b/action.yml index 0011139..5d8d43b 100644 --- a/action.yml +++ b/action.yml @@ -1,14 +1,21 @@ # action.yml -name: 'Hello World' -description: 'Greet someone and record the time' +name: 'Code Quality Score' +description: 'Calculate the code quality score for the code based on reek, flay, and flog' inputs: who-to-greet: # id of input description: 'Who to greet' required: true default: 'World' outputs: - time: # id of output - description: 'The time we greeted you' + total_score: # id of output + description: 'The total score' + similarity_score_per_file: + 'Average similarity score by code files (based on flay)', + abc_method_average: + 'Average abc method score (based on flog)', + code_smells_per_file: + 'Average number of code smells per file (based on reek)' + runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 297a521..01b3dec 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,8 @@ #!/bin/sh -l echo "Hello $1" -time=$(date) -echo "time=$time" >> $GITHUB_OUTPUT \ No newline at end of file + +echo "abc_method_average=6.4" >> $GITHUB_OUTPUT +echo "code_smells_per_file=0.5" >> $GITHUB_OUTPUT +echo "similarity_score_per_file=12.0" >> $GITHUB_OUTPUT +echo "total_score=18.9" >> $GITHUB_OUTPUT diff --git a/lib/code_quality_score/lib.rb b/lib/code_quality_score/lib.rb index 9fa1189..70b8e6d 100644 --- a/lib/code_quality_score/lib.rb +++ b/lib/code_quality_score/lib.rb @@ -16,7 +16,7 @@ def structural_similarity_score_per_file(solution) def abc_method_average_score(solution) score_line = `flog #{solution[:relative_path]}#{folder(solution)}/* | head -n 2 | tail -1` - Float(score_line.split(":").first) + Float(score_line.split(":").first).round(2) end def code_smells_per_file(solution) diff --git a/lib/code_quality_score/version.rb b/lib/code_quality_score/version.rb index 9d11d59..b84a0de 100644 --- a/lib/code_quality_score/version.rb +++ b/lib/code_quality_score/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module CodeQualityScore - VERSION = "0.1.7" + VERSION = "0.1.8" end From 337676043126bc3cd1b14151f7af63f9368d2811 Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 14:09:07 +1200 Subject: [PATCH 04/17] fix: wasn't running because I missed the descriptions --- action.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/action.yml b/action.yml index 5d8d43b..b22d05b 100644 --- a/action.yml +++ b/action.yml @@ -2,22 +2,22 @@ name: 'Code Quality Score' description: 'Calculate the code quality score for the code based on reek, flay, and flog' inputs: - who-to-greet: # id of input - description: 'Who to greet' + code_folder: # id of input + description: 'Code folder (either 'app' or 'lib')' required: true - default: 'World' + default: 'app' outputs: total_score: # id of output description: 'The total score' similarity_score_per_file: - 'Average similarity score by code files (based on flay)', + description: 'Average similarity score by code files (based on flay)', abc_method_average: - 'Average abc method score (based on flog)', + description: 'Average abc method score (based on flog)', code_smells_per_file: - 'Average number of code smells per file (based on reek)' + description: 'Average number of code smells per file (based on reek)' runs: using: 'docker' image: 'Dockerfile' args: - - ${{ inputs.who-to-greet }} \ No newline at end of file + - ${{ inputs.code_folder }} \ No newline at end of file From 4308b48fa912e911c4eee99694708550093eef4a Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 14:24:08 +1200 Subject: [PATCH 05/17] fix: trying to fix more --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b22d05b..a42efa3 100644 --- a/action.yml +++ b/action.yml @@ -3,7 +3,7 @@ name: 'Code Quality Score' description: 'Calculate the code quality score for the code based on reek, flay, and flog' inputs: code_folder: # id of input - description: 'Code folder (either 'app' or 'lib')' + description: Code folder (either app or lib) required: true default: 'app' outputs: From 1d91b7b1522d908ce2c7a79255c5315e37a68d48 Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 14:28:07 +1200 Subject: [PATCH 06/17] fix: still trying to fix --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index a42efa3..06c9c31 100644 --- a/action.yml +++ b/action.yml @@ -2,8 +2,8 @@ name: 'Code Quality Score' description: 'Calculate the code quality score for the code based on reek, flay, and flog' inputs: - code_folder: # id of input - description: Code folder (either app or lib) + code-folder: # id of input + description: 'Code folder (either app or lib)' required: true default: 'app' outputs: @@ -20,4 +20,4 @@ runs: using: 'docker' image: 'Dockerfile' args: - - ${{ inputs.code_folder }} \ No newline at end of file + - ${{ inputs.code-folder }} \ No newline at end of file From 032f93029285a43ffbeccb1ac2d68c12230c8154 Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 14:31:01 +1200 Subject: [PATCH 07/17] fix: fixed now? --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 06c9c31..4bf81c6 100644 --- a/action.yml +++ b/action.yml @@ -10,9 +10,9 @@ outputs: total_score: # id of output description: 'The total score' similarity_score_per_file: - description: 'Average similarity score by code files (based on flay)', + description: 'Average similarity score by code files (based on flay)' abc_method_average: - description: 'Average abc method score (based on flog)', + description: 'Average abc method score (based on flog)' code_smells_per_file: description: 'Average number of code smells per file (based on reek)' From 7d3375304a120395d5f59a503fe4cb9181f31b7f Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 14:43:01 +1200 Subject: [PATCH 08/17] fix: trying to get output actually working --- entrypoint.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 01b3dec..4ee9401 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,7 +2,9 @@ echo "Hello $1" -echo "abc_method_average=6.4" >> $GITHUB_OUTPUT -echo "code_smells_per_file=0.5" >> $GITHUB_OUTPUT -echo "similarity_score_per_file=12.0" >> $GITHUB_OUTPUT -echo "total_score=18.9" >> $GITHUB_OUTPUT +echo “::set-output name=total_score::18.9” + +# echo "abc_method_average=6.4" >> $GITHUB_OUTPUT +# echo "code_smells_per_file=0.5" >> $GITHUB_OUTPUT +# echo "similarity_score_per_file=12.0" >> $GITHUB_OUTPUT +# echo "total_score=18.9" >> $GITHUB_OUTPUT From b325e191841d282abf68d8fdf61eed8295bee0f5 Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 15:09:44 +1200 Subject: [PATCH 09/17] feat: switching to ruby gem, attempting to run the actual code --- Dockerfile | 13 +++++++++---- entrypoint.sh | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index e175586..f82eb6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,15 @@ # Container image that runs your code -FROM alpine:3.10 +FROM ruby:3.0-alpine -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh +RUN mkdir /gem + +COPY . /gem + +RUN cd /gem + +RUN bundle install RUN chmod +x entrypoint.sh # Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/gem/entrypoint.sh"] \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 4ee9401..6d6115b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,6 +2,8 @@ echo "Hello $1" +/gem/exe/code_quality_score $1 . + echo “::set-output name=total_score::18.9” # echo "abc_method_average=6.4" >> $GITHUB_OUTPUT From ae16fb64f93db3e24a7dc65c96cd60efe6810aed Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 15:25:02 +1200 Subject: [PATCH 10/17] fix: the image builds at least --- Dockerfile | 10 +++++++--- action_stuff/Gemfile | 5 +++++ entrypoint.sh => action_stuff/entrypoint.sh | 0 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 action_stuff/Gemfile rename entrypoint.sh => action_stuff/entrypoint.sh (100%) diff --git a/Dockerfile b/Dockerfile index f82eb6e..acec0c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,19 @@ # Container image that runs your code FROM ruby:3.0-alpine -RUN mkdir /gem +RUN apk add git -COPY . /gem +RUN mkdir /gem && mkdir /app -RUN cd /gem +COPY ./action_stuff /gem + +WORKDIR "/gem" RUN bundle install RUN chmod +x entrypoint.sh +WORKDIR "/app" + # Code file to execute when the docker container starts up (`entrypoint.sh`) ENTRYPOINT ["/gem/entrypoint.sh"] \ No newline at end of file diff --git a/action_stuff/Gemfile b/action_stuff/Gemfile new file mode 100644 index 0000000..09b127e --- /dev/null +++ b/action_stuff/Gemfile @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "code_quality_score", git: "https://github.com/boost/code_quality_score.git" diff --git a/entrypoint.sh b/action_stuff/entrypoint.sh similarity index 100% rename from entrypoint.sh rename to action_stuff/entrypoint.sh From ea4666c21c950b9ae44de2676224a7d97cba3d6d Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 15:29:40 +1200 Subject: [PATCH 11/17] fix: binstubs --- Dockerfile | 1 + action_stuff/entrypoint.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index acec0c1..92a1a68 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ COPY ./action_stuff /gem WORKDIR "/gem" RUN bundle install +RUN bundle binstubs code_quality_score RUN chmod +x entrypoint.sh diff --git a/action_stuff/entrypoint.sh b/action_stuff/entrypoint.sh index 6d6115b..be311f1 100644 --- a/action_stuff/entrypoint.sh +++ b/action_stuff/entrypoint.sh @@ -2,7 +2,7 @@ echo "Hello $1" -/gem/exe/code_quality_score $1 . +/gem/bin/code_quality_score $1 . echo “::set-output name=total_score::18.9” From 0c07c7868f95bd883b1b60f5d61c9b448825f57e Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 15:35:53 +1200 Subject: [PATCH 12/17] temp: debugging where we are --- action_stuff/entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/action_stuff/entrypoint.sh b/action_stuff/entrypoint.sh index be311f1..bbc78cf 100644 --- a/action_stuff/entrypoint.sh +++ b/action_stuff/entrypoint.sh @@ -2,6 +2,9 @@ echo "Hello $1" +echo `pwd` +echo `ls` + /gem/bin/code_quality_score $1 . echo “::set-output name=total_score::18.9” From b551e4ff99f4e8a2f26101836fac8627cf73fa3b Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 15:45:23 +1200 Subject: [PATCH 13/17] more debugging --- action_stuff/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action_stuff/entrypoint.sh b/action_stuff/entrypoint.sh index bbc78cf..52b7bb4 100644 --- a/action_stuff/entrypoint.sh +++ b/action_stuff/entrypoint.sh @@ -3,7 +3,7 @@ echo "Hello $1" echo `pwd` -echo `ls` +echo `file app` /gem/bin/code_quality_score $1 . From ab822e931853434ed2a5ccc11d1cbc338eab00d5 Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 16:06:18 +1200 Subject: [PATCH 14/17] test: trying to isolate the mount issue --- Dockerfile | 16 +++------------- action_stuff/entrypoint.sh | 2 +- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 92a1a68..751ad27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,20 +1,10 @@ # Container image that runs your code FROM ruby:3.0-alpine -RUN apk add git - -RUN mkdir /gem && mkdir /app - -COPY ./action_stuff /gem - -WORKDIR "/gem" - -RUN bundle install -RUN bundle binstubs code_quality_score +# Copies your code file from your action repository to the filesystem path `/` of the container +COPY /bin/entrypoint.sh /entrypoint.sh RUN chmod +x entrypoint.sh -WORKDIR "/app" - # Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/gem/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/action_stuff/entrypoint.sh b/action_stuff/entrypoint.sh index 52b7bb4..9b7ef85 100644 --- a/action_stuff/entrypoint.sh +++ b/action_stuff/entrypoint.sh @@ -5,7 +5,7 @@ echo "Hello $1" echo `pwd` echo `file app` -/gem/bin/code_quality_score $1 . +# /gem/bin/code_quality_score $1 . echo “::set-output name=total_score::18.9” From 0bc24cfe1f53937412c6aa1ae2f001dcc788757d Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 16:09:20 +1200 Subject: [PATCH 15/17] test: again, with fixes --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 751ad27..e54a0ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ruby:3.0-alpine # Copies your code file from your action repository to the filesystem path `/` of the container -COPY /bin/entrypoint.sh /entrypoint.sh +COPY action_stuff/entrypoint.sh /entrypoint.sh RUN chmod +x entrypoint.sh From 77c1a9bcbb91eba816aafef9e046cb2d1ebdbce2 Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 16:11:50 +1200 Subject: [PATCH 16/17] fix: again --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e54a0ff..e358b1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Container image that runs your code -FROM ruby:3.0-alpine +FROM alpine:3.10 # Copies your code file from your action repository to the filesystem path `/` of the container COPY action_stuff/entrypoint.sh /entrypoint.sh From 0ffc68bd75c0c9e7a30c35026a939c23989cb69b Mon Sep 17 00:00:00 2001 From: Isabel Anastasiadis Date: Fri, 26 May 2023 16:25:53 +1200 Subject: [PATCH 17/17] fix: abandoning docker actions --- Dockerfile | 10 ---------- action.yml | 23 ----------------------- action_stuff/Gemfile | 5 ----- action_stuff/entrypoint.sh | 15 --------------- 4 files changed, 53 deletions(-) delete mode 100644 Dockerfile delete mode 100644 action.yml delete mode 100644 action_stuff/Gemfile delete mode 100644 action_stuff/entrypoint.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e358b1a..0000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -# Container image that runs your code -FROM alpine:3.10 - -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY action_stuff/entrypoint.sh /entrypoint.sh - -RUN chmod +x entrypoint.sh - -# Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/action.yml b/action.yml deleted file mode 100644 index 4bf81c6..0000000 --- a/action.yml +++ /dev/null @@ -1,23 +0,0 @@ -# action.yml -name: 'Code Quality Score' -description: 'Calculate the code quality score for the code based on reek, flay, and flog' -inputs: - code-folder: # id of input - description: 'Code folder (either app or lib)' - required: true - default: 'app' -outputs: - total_score: # id of output - description: 'The total score' - similarity_score_per_file: - description: 'Average similarity score by code files (based on flay)' - abc_method_average: - description: 'Average abc method score (based on flog)' - code_smells_per_file: - description: 'Average number of code smells per file (based on reek)' - -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.code-folder }} \ No newline at end of file diff --git a/action_stuff/Gemfile b/action_stuff/Gemfile deleted file mode 100644 index 09b127e..0000000 --- a/action_stuff/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -gem "code_quality_score", git: "https://github.com/boost/code_quality_score.git" diff --git a/action_stuff/entrypoint.sh b/action_stuff/entrypoint.sh deleted file mode 100644 index 9b7ef85..0000000 --- a/action_stuff/entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh -l - -echo "Hello $1" - -echo `pwd` -echo `file app` - -# /gem/bin/code_quality_score $1 . - -echo “::set-output name=total_score::18.9” - -# echo "abc_method_average=6.4" >> $GITHUB_OUTPUT -# echo "code_smells_per_file=0.5" >> $GITHUB_OUTPUT -# echo "similarity_score_per_file=12.0" >> $GITHUB_OUTPUT -# echo "total_score=18.9" >> $GITHUB_OUTPUT