From 15c4de1744fcd66ce9b0ce24a35241c1e44ba094 Mon Sep 17 00:00:00 2001 From: Bogdan Savko Date: Sun, 17 Mar 2024 20:21:37 +0300 Subject: [PATCH 1/8] [#211] Fix missing cast to hash in repo discovery script --- steps/discover-repos.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steps/discover-repos.rb b/steps/discover-repos.rb index cd3fac79..a26a979d 100755 --- a/steps/discover-repos.rb +++ b/steps/discover-repos.rb @@ -102,7 +102,7 @@ puts "Found #{found.count} total repositories in GitHub" if found.count > opts[:total] - found = found.first(opts[:total]) + found = found.first(opts[:total]).to_h puts "We will use only the first #{opts[:total]} repositories" end From 430a73fcd8e11ed1f0fe6385fe841e7225b4ff72 Mon Sep 17 00:00:00 2001 From: howcanunot Date: Mon, 18 Mar 2024 03:00:03 +0300 Subject: [PATCH 2/8] install tlmgr util if necessary --- steps/install.sh | 100 +++++++++++++---------------------------------- 1 file changed, 28 insertions(+), 72 deletions(-) diff --git a/steps/install.sh b/steps/install.sh index 3ed677d8..8cd981f9 100755 --- a/steps/install.sh +++ b/steps/install.sh @@ -47,77 +47,40 @@ if [ -n "${linux}" ]; then apt-get install -y coreutils fi -if ! parallel --version >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get -y install parallel - else - echo "Install 'parallel' somehow" - exit 1 +install_or_quit() { + if ! dpkg -s "$1" >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get -y install "$1" + else + echo "Install '$1' somehow" + exit 1 + fi fi -fi - -if ! bc -v >/dev/null 2>&1; then +} + +install_or_quit 'parallel' +install_or_quit 'bc' +install_or_quit 'cloc' +install_or_quit 'jq' +install_or_quit 'xpdf' +install_or_quit 'shellcheck' +install_or_quit 'aspell' +install_or_quit 'xmlstarlet' + +if [ ! -f "/usr/local/texlive/$(date +%Y)/bin/x86_64-linux/tlmgr" ]; then if [ -n "${linux}" ]; then - apt-get install -y bc + wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \ + zcat < install-tl-unx.tar.gz | tar xf - && \ + rm install-tl-unx.tar.gz && \ + cd install-tl-$(date +%Y)* && \ + perl ./install-tl --scheme=e --no-interaction else - echo "Install 'GNU bc' somehow" + echo "Install 'texlive-base' somehow" exit 1 fi fi -if ! cloc --version >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get install -y cloc - else - echo "Install 'cloc' somehow" - exit 1 - fi -fi - -if ! jq --version >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get install -y jq - else - echo "Install 'jq' somehow" - exit 1 - fi -fi - -if ! pdftotext -v >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get install -y xpdf - else - echo "Install 'poppler' somehow" - exit 1 - fi -fi - -if ! shellcheck --version >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get install -y shellcheck - else - echo "Install 'shellcheck' somehow" - exit 1 - fi -fi - -if ! aspell --version >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get install -y aspell - else - echo "Install 'GNU aspell' somehow" - exit 1 - fi -fi - -if ! xmlstarlet --version >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get install -y xmlstarlet - else - echo "Install 'xmlstarlet' somehow" - exit 1 - fi -fi +export PATH=/usr/local/texlive/$(date +%Y)/bin/x86_64-linux:$PATH if [ ! -e "${HOME}/texmf" ]; then $SUDO tlmgr init-usertree @@ -132,14 +95,7 @@ done < <( cut -d' ' -f2 "${root}/../DEPENDS.txt" | uniq ) $SUDO tlmgr --verify-repo=none install "${packages[@]}" $SUDO tlmgr --verify-repo=none update --no-auto-remove "${packages[@]}" || echo 'Failed to update' -if ! pygmentize -V >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get install -y python3-pygments - else - echo "Install 'python3-pygments' somehow" - exit 1 - fi -fi +install_or_quit 'python3-pygments' $SUDO python3 -m pip install --upgrade pip $SUDO python3 -m pip install -r "${LOCAL}/requirements.txt" From e9e700c81b6cf41deeeffd387d50c6eee43c26e5 Mon Sep 17 00:00:00 2001 From: howcanunot Date: Mon, 18 Mar 2024 03:13:01 +0300 Subject: [PATCH 3/8] Revert "install tlmgr util if necessary" This reverts commit 430a73fcd8e11ed1f0fe6385fe841e7225b4ff72. --- steps/install.sh | 100 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 28 deletions(-) diff --git a/steps/install.sh b/steps/install.sh index 8cd981f9..3ed677d8 100755 --- a/steps/install.sh +++ b/steps/install.sh @@ -47,40 +47,77 @@ if [ -n "${linux}" ]; then apt-get install -y coreutils fi -install_or_quit() { - if ! dpkg -s "$1" >/dev/null 2>&1; then - if [ -n "${linux}" ]; then - apt-get -y install "$1" - else - echo "Install '$1' somehow" - exit 1 - fi +if ! parallel --version >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get -y install parallel + else + echo "Install 'parallel' somehow" + exit 1 fi -} - -install_or_quit 'parallel' -install_or_quit 'bc' -install_or_quit 'cloc' -install_or_quit 'jq' -install_or_quit 'xpdf' -install_or_quit 'shellcheck' -install_or_quit 'aspell' -install_or_quit 'xmlstarlet' - -if [ ! -f "/usr/local/texlive/$(date +%Y)/bin/x86_64-linux/tlmgr" ]; then +fi + +if ! bc -v >/dev/null 2>&1; then if [ -n "${linux}" ]; then - wget https://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \ - zcat < install-tl-unx.tar.gz | tar xf - && \ - rm install-tl-unx.tar.gz && \ - cd install-tl-$(date +%Y)* && \ - perl ./install-tl --scheme=e --no-interaction + apt-get install -y bc else - echo "Install 'texlive-base' somehow" + echo "Install 'GNU bc' somehow" exit 1 fi fi -export PATH=/usr/local/texlive/$(date +%Y)/bin/x86_64-linux:$PATH +if ! cloc --version >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get install -y cloc + else + echo "Install 'cloc' somehow" + exit 1 + fi +fi + +if ! jq --version >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get install -y jq + else + echo "Install 'jq' somehow" + exit 1 + fi +fi + +if ! pdftotext -v >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get install -y xpdf + else + echo "Install 'poppler' somehow" + exit 1 + fi +fi + +if ! shellcheck --version >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get install -y shellcheck + else + echo "Install 'shellcheck' somehow" + exit 1 + fi +fi + +if ! aspell --version >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get install -y aspell + else + echo "Install 'GNU aspell' somehow" + exit 1 + fi +fi + +if ! xmlstarlet --version >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get install -y xmlstarlet + else + echo "Install 'xmlstarlet' somehow" + exit 1 + fi +fi if [ ! -e "${HOME}/texmf" ]; then $SUDO tlmgr init-usertree @@ -95,7 +132,14 @@ done < <( cut -d' ' -f2 "${root}/../DEPENDS.txt" | uniq ) $SUDO tlmgr --verify-repo=none install "${packages[@]}" $SUDO tlmgr --verify-repo=none update --no-auto-remove "${packages[@]}" || echo 'Failed to update' -install_or_quit 'python3-pygments' +if ! pygmentize -V >/dev/null 2>&1; then + if [ -n "${linux}" ]; then + apt-get install -y python3-pygments + else + echo "Install 'python3-pygments' somehow" + exit 1 + fi +fi $SUDO python3 -m pip install --upgrade pip $SUDO python3 -m pip install -r "${LOCAL}/requirements.txt" From d585d9a9c8543a085330ebb7da69307ad8c7ee02 Mon Sep 17 00:00:00 2001 From: Bogdan Savko Date: Mon, 18 Mar 2024 19:16:13 +0300 Subject: [PATCH 4/8] extra test for discovery repos script --- steps/discover-repos.rb | 3 ++- tests/steps/test-discover-repos.sh | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/steps/discover-repos.rb b/steps/discover-repos.rb index a26a979d..cfbeea33 100755 --- a/steps/discover-repos.rb +++ b/steps/discover-repos.rb @@ -75,10 +75,11 @@ break end json = if opts[:dry] - { items: page > 100 ? [] : [{ full_name: "foo/#{Random.hex(5)}", created_at: Time.now }] } + { items: page > 100 ? [] : Array.new(size) { { full_name: "foo/#{Random.hex(5)}", created_at: Time.now } } } else github.search_repositories(query, per_page: size, page: page) end + puts(json) json[:items].each do |i| found[i[:full_name]] = { full_name: i[:full_name], diff --git a/tests/steps/test-discover-repos.sh b/tests/steps/test-discover-repos.sh index 5eaa9611..bd16f440 100755 --- a/tests/steps/test-discover-repos.sh +++ b/tests/steps/test-discover-repos.sh @@ -30,7 +30,7 @@ tex=${TARGET}/foo.tex { rm -f "${csv}" - msg=$("${LOCAL}/steps/discover-repos.rb" --dry --pause=0 --total=3 --min-stars=100 --max-stars=1000 "--csv=${csv}" "--tex=${tex}") + msg=$("${LOCAL}/steps/discover-repos.rb" --dry --pause=0 --total=3 --page-size=1 --min-stars=100 --max-stars=1000 "--csv=${csv}" "--tex=${tex}") echo "${msg}" echo "${msg}" | grep "Found 1 repositories in page #0" echo "${msg}" | grep "Found 3 total repositories in GitHub" @@ -38,4 +38,16 @@ tex=${TARGET}/foo.tex test -s "${tex}" test "$(wc -l < "${csv}" | xargs)" = '4' } > "${stdout}" 2>&1 -echo "👍🏻 A few repositories discovered correctly" +echo "👍🏻 Small repositories discovered test is succeed" + +{ + rm -f "${csv}" + msg=$("${LOCAL}/steps/discover-repos.rb" --dry --pause=0 --total=35 --page-size=30 --min-stars=100 --max-stars=1000 "--csv=${csv}" "--tex=${tex}") + echo "${msg}" + echo "${msg}" | grep "Found 60 total repositories in GitHub" + echo "${msg}" | grep "We will use only the first 35 repositories" + test -e "${csv}" + test -s "${tex}" + test "$(wc -l < "${csv}" | xargs)" = '36' +} > "${stdout}" 2>&1 +echo "👍🏻 Medium repositories discovered test is succeed" \ No newline at end of file From 5e26341892d1618ac2b25a479d7d018749664065 Mon Sep 17 00:00:00 2001 From: Bogdan Savko Date: Mon, 18 Mar 2024 19:24:06 +0300 Subject: [PATCH 5/8] codestyle --- tests/steps/test-discover-repos.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/steps/test-discover-repos.sh b/tests/steps/test-discover-repos.sh index bd16f440..3e0f55bc 100755 --- a/tests/steps/test-discover-repos.sh +++ b/tests/steps/test-discover-repos.sh @@ -50,4 +50,4 @@ echo "👍🏻 Small repositories discovered test is succeed" test -s "${tex}" test "$(wc -l < "${csv}" | xargs)" = '36' } > "${stdout}" 2>&1 -echo "👍🏻 Medium repositories discovered test is succeed" \ No newline at end of file +echo "👍🏻 Medium repositories discovered test is succeed" From a99aaa7e9e5390b3f56cdb6888c4bf49a0048ca9 Mon Sep 17 00:00:00 2001 From: Bogdan Savko Date: Mon, 18 Mar 2024 19:27:12 +0300 Subject: [PATCH 6/8] misspell --- tests/steps/test-discover-repos.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/steps/test-discover-repos.sh b/tests/steps/test-discover-repos.sh index 3e0f55bc..8cd63bb0 100755 --- a/tests/steps/test-discover-repos.sh +++ b/tests/steps/test-discover-repos.sh @@ -38,7 +38,7 @@ tex=${TARGET}/foo.tex test -s "${tex}" test "$(wc -l < "${csv}" | xargs)" = '4' } > "${stdout}" 2>&1 -echo "👍🏻 Small repositories discovered test is succeed" +echo "👍🏻 Small repositories discovery test is succeed" { rm -f "${csv}" @@ -50,4 +50,4 @@ echo "👍🏻 Small repositories discovered test is succeed" test -s "${tex}" test "$(wc -l < "${csv}" | xargs)" = '36' } > "${stdout}" 2>&1 -echo "👍🏻 Medium repositories discovered test is succeed" +echo "👍🏻 Medium repositories discovery test is succeed" From 0c149f929a9df1d7854c6aba1b4bcf8dbe55a4e6 Mon Sep 17 00:00:00 2001 From: Bogdan Savko Date: Wed, 20 Mar 2024 18:31:25 +0300 Subject: [PATCH 7/8] remove debug log --- steps/discover-repos.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/steps/discover-repos.rb b/steps/discover-repos.rb index cfbeea33..9b4b2219 100755 --- a/steps/discover-repos.rb +++ b/steps/discover-repos.rb @@ -79,7 +79,6 @@ else github.search_repositories(query, per_page: size, page: page) end - puts(json) json[:items].each do |i| found[i[:full_name]] = { full_name: i[:full_name], @@ -103,7 +102,7 @@ puts "Found #{found.count} total repositories in GitHub" if found.count > opts[:total] - found = found.first(opts[:total]).to_h + found = found.first(opts[:total]) puts "We will use only the first #{opts[:total]} repositories" end From 4ebcb9eebbf72d926a73497ae3ef2a764f02fcf2 Mon Sep 17 00:00:00 2001 From: Bogdan Savko Date: Wed, 20 Mar 2024 18:35:00 +0300 Subject: [PATCH 8/8] missing cast --- steps/discover-repos.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/steps/discover-repos.rb b/steps/discover-repos.rb index 9b4b2219..74c14742 100755 --- a/steps/discover-repos.rb +++ b/steps/discover-repos.rb @@ -102,7 +102,7 @@ puts "Found #{found.count} total repositories in GitHub" if found.count > opts[:total] - found = found.first(opts[:total]) + found = found.first(opts[:total]).to_h puts "We will use only the first #{opts[:total]} repositories" end