Skip to content

Commit

Permalink
Issue 43 automated testing numbers (#87)
Browse files Browse the repository at this point in the history
write issues into environment variables and use them for file existing test

code can be reduced, if the variables can be set up in an extra job.
but it was not working , when tested
see [documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs)

closes #43 
closes #59
  • Loading branch information
joergi authored Oct 28, 2022
1 parent 999f389 commit 895bf9e
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 106 deletions.
38 changes: 19 additions & 19 deletions .github/workflows/testing-educational-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
powershell:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3.1.0
- name: Download Education Issues
id: educationIssues
shell: pwsh
run: ./windows/magpi-education-downloader.ps1
- name: "Check file existence Windows"
id: check_files
uses: andstor/file-existence-action@v1.1.0
with:
files: "education_issues/MagPi-EduEdition02.pdf"
allow_failure: false
- name: lslah issues
run: Get-ChildItem –path D:\a\MagPiDownloader\MagPiDownloader\education_issues
- name: File exists
if: steps.check_files.outputs.files_exists == 'false'
run: exit 1
# powershell:
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v3.1.0
# - name: Download Education Issues
# id: educationIssues
# shell: pwsh
# run: ./windows/magpi-education-downloader.ps1
# - name: "Check file existence Windows"
# id: check_files
# uses: andstor/file-existence-action@v1.1.0
# with:
# files: "education_issues/MagPi-EduEdition02.pdf"
# allow_failure: false
# - name: lslah issues
# run: Get-ChildItem –path D:\a\MagPiDownloader\MagPiDownloader\education_issues
# - name: File exists
# if: steps.check_files.outputs.files_exists == 'false'
# run: exit 1

bash-linux:
runs-on: ubuntu-latest
Expand Down
71 changes: 48 additions & 23 deletions .github/workflows/testing-regular-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,41 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
read_recent_issue:
runs-on: ubuntu-latest


powershell:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: pCYSl5EDgo/cat@master
id: read_recent
with:
path: issues.txt
- run: echo $TEXT
env:
TEXT: ${{ steps.read_recent.outputs.text }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
powershell:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3.1.0
path: sources-for-download/regular-issues.txt
- run: |
echo "ISSUE_NUMBER=${{ steps.read_recent.outputs.text }}" >> $GITHUB_ENV
echo "ISSUE_MINUS_ONE=$((${{ steps.read_recent.outputs.text }}-1))" >> $GITHUB_ENV
echo "ISSUE_MINUS_FIVE=$((${{ steps.read_recent.outputs.text }}-5))" >> $GITHUB_ENV
echo "ISSUE_MINUS_SIX=$((${{ steps.read_recent.outputs.text }}-6))" >> $GITHUB_ENV
- name: Download Issues With end limit
id: normalIssuesWithEndLimit
shell: pwsh
run: ./windows/magpi-issue-downloader.ps1 -l 3

- name: Download Issues with start and end limit
id: normalIssuesWithRange
shell: pwsh
run: ./windows/magpi-issue-downloader.ps1 -f 95 -l 96
- name: Download Issues with start and end limit
run: ./windows/magpi-issue-downloader.ps1 -f ${{ env.ISSUE_MINUS_SIX }} -l ${{ env.ISSUE_MINUS_FIVE }}

- name: Download Issues with start limit
id: normalIssuesWithStartingLimit
shell: pwsh
run: ./windows/magpi-issue-downloader.ps1 -f 99
run: ./windows/magpi-issue-downloader.ps1 -f $((${{ env.ISSUE_NUMBER }}-1))

- name: "Check file existence Windows"
id: check_files
uses: andstor/file-existence-action@v1.1.0
with:
files: "issues/the-magpi-issue-3.pdf, issues/the-magpi-issue-96.pdf, issues/the-magpi-issue-101.pdf"
files: "issues/the-magpi-issue-1.pdf, issues/the-magpi-issue-1.pdf,, issues/the-magpi-issue-${{ env.ISSUE_MINUS_SIX }}.pdf, issues/the-magpi-issue-${{ env.ISSUE_MINUS_FIVE }}.pdf, issues/the-magpi-issue-${{ env.ISSUE_MINUS_ONE }}.pdf, issues/the-magpi-issue-${{ env.ISSUE_NUMBER }}.pdf"
allow_failure: false
- name: lslah issues
run: Get-ChildItem –path D:\a\MagPiDownloader\MagPiDownloader\issues
Expand All @@ -57,21 +58,34 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: pCYSl5EDgo/cat@master
id: read_recent
with:
path: sources-for-download/regular-issues.txt
- run: |
echo "ISSUE_NUMBER=${{ steps.read_recent.outputs.text }}" >> $GITHUB_ENV
echo "ISSUE_MINUS_ONE=$((${{ steps.read_recent.outputs.text }}-1))" >> $GITHUB_ENV
echo "ISSUE_MINUS_FIVE=$((${{ steps.read_recent.outputs.text }}-5))" >> $GITHUB_ENV
echo "ISSUE_MINUS_SIX=$((${{ steps.read_recent.outputs.text }}-6))" >> $GITHUB_ENV
- name: Download Issues with end limit
id: normalIssuesWithEndLimit
run: bash ./linux_mac/magpi-issue-downloader.sh -l 2

- name: Download Issues with start limit
id: normalIssuesWithStartLimit
run: bash ./linux_mac/magpi-issue-downloader.sh -f 99
run: bash ./linux_mac/magpi-issue-downloader.sh -f $((${{ env.ISSUE_NUMBER }}-1))

- name: Download Issues with start and end limit
id: normalIssuesWithRange
run: bash ./linux_mac/magpi-issue-downloader.sh -f 95 -l 96
run: bash ./linux_mac/magpi-issue-downloader.sh -f ${{ env.ISSUE_MINUS_SIX }} -l ${{ env.ISSUE_MINUS_FIVE }}

# check if files are existing
- name: "Check file existence Linux"
id: check_files
uses: andstor/file-existence-action@v1.1.0
with:
files: "issues/MagPi02.pdf, issues/MagPi96.pdf, issues/MagPi101.pdf"
files: "issues/MagPi01.pdf, issues/MagPi02.pdf, issues/MagPi${{ env.ISSUE_MINUS_SIX }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_FIVE }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_ONE }}.pdf, issues/MagPi${{ env.ISSUE_NUMBER }}.pdf"
allow_failure: false
- name: lslah
run: ls -lah issues/
Expand All @@ -82,24 +96,35 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: pCYSl5EDgo/cat@master
id: read_recent
with:
path: sources-for-download/regular-issues.txt
- run: |
echo "ISSUE_NUMBER=${{ steps.read_recent.outputs.text }}" >> $GITHUB_ENV
echo "ISSUE_MINUS_ONE=$((${{ steps.read_recent.outputs.text }}-1))" >> $GITHUB_ENV
echo "ISSUE_MINUS_FIVE=$((${{ steps.read_recent.outputs.text }}-5))" >> $GITHUB_ENV
echo "ISSUE_MINUS_SIX=$((${{ steps.read_recent.outputs.text }}-6))" >> $GITHUB_ENV
- name: Download Issues with end limit
id: normalIssuesWithEndLimit
run: bash ./linux_mac/magpi-issue-downloader.sh -l 2

- name: Download Issues with start limit
id: normalIssuesWithStartLimit
run: bash ./linux_mac/magpi-issue-downloader.sh -f 99
run: bash ./linux_mac/magpi-issue-downloader.sh -f $((${{ env.ISSUE_NUMBER }}-1))
- name: Download Issues with start and end limit
id: normalIssuesWithRange
run: bash ./linux_mac/magpi-issue-downloader.sh -f 95 -l 96
run: bash ./linux_mac/magpi-issue-downloader.sh -f ${{ env.ISSUE_MINUS_SIX }} -l ${{ env.ISSUE_MINUS_FIVE }}
# check if files are existing
- name: "Check file existence MacOs"
id: check_files
uses: andstor/file-existence-action@v1.1.0
with:
files: "issues/MagPi02.pdf, issues/MagPi95.pdf, issues/MagPi101.pdf"
files: "issues/MagPi01.pdf, issues/MagPi02.pdf, issues/MagPi${{ env.ISSUE_MINUS_SIX }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_FIVE }}.pdf, issues/MagPi${{ env.ISSUE_MINUS_ONE }}.pdf, issues/MagPi${{ env.ISSUE_NUMBER }}.pdf"
allow_failure: false
- name: lslah
run: ls -lah issues/
- name: File exists
if: steps.check_files.outputs.files_exists == 'false'
run: exit 1
run: exit 1
4 changes: 2 additions & 2 deletions .github/workflows/testing-special-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Download Special Issues Mac
id: specialIssues
run: bash ./linux_mac/magpi-special-issue-downloader.sh
# check if files are existing
# check if files are existing
- name: "Check file existence MacOs special issues"
id: check_files
uses: andstor/file-existence-action@v1.1.0
Expand All @@ -69,4 +69,4 @@ jobs:
run: ls -lah special_issues/
- name: File exists
if: steps.check_files.outputs.files_exists == 'false'
run: exit 1
run: exit 1
1 change: 0 additions & 1 deletion issues.txt

This file was deleted.

122 changes: 61 additions & 61 deletions windows/magpi-issue-downloader.ps1
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
# ------------------------------------------------------------------
# [Author] rubemlrm - https://github.com/joergi/MagPiDownloader
# downloader for all MagPi issues
# they are downloadable for free under https://www.raspberrypi.org/magpi/issues/
# or you can buy the paper issues under: http://swag.raspberrypi.org/collections/magpi
# this script is under GNU GENERAL PUBLIC LICENSE
# ------------------------------------------------------------------

# VERSION=0.1.2
# USAGE="Usage: sh magpi-issue-downloader.sh [-f firstissue] [-l lastissue]"

Param(
[string]$f,
[string]$l
)

# control variables
$i = 1
$baseDir = (Split-Path -Path $PSScriptRoot -Parent)
$issues = Get-Content "$baseDir\sources-for-download\regular-issues.txt" -First 1
$baseUrl = "https://magpi.raspberrypi.org/issues/"
$web = New-Object system.net.webclient
$errorCount = 0

# Check if directory dont exist and try create
if ( -Not (Test-Path -Path "$baseDir\issues" ) ) {
New-Item -ItemType directory -Path "$baseDir\issues"
}


if ($f) {
$i = [int]$f
}

if ($l) {
$issues = [int]$l
}

do {
#start scrapping directory and download files

$tempCounter = if ($i -le 9) { "{0:00}" -f $i } Else { $i }

$fileReponse = ((Invoke-WebRequest -UseBasicParsing "$baseUrl$tempCounter/pdf").Links | Where-Object { $_.href -like "http*" } | Where-Object class -eq c-link)
if ($fileReponse) {
try {
$web.DownloadFile($fileReponse.href, "$baseDir\issues\" + $fileReponse.download)
Write-Verbose -Message "Downloaded from $fileReponse.href"
}
Catch {
Write-Verbose -Message $_.Exception | format-list -force
Write-Verbose -Message "Ocorred an error trying download $fileReponse.download"
$errorCount++
}
}
$i++
} While ($i -le $issues)

if ($errorCount -gt 0) {
exit 1
}
## ------------------------------------------------------------------
## [Author] rubemlrm - https://github.com/joergi/MagPiDownloader
## downloader for all MagPi issues
## they are downloadable for free under https://www.raspberrypi.org/magpi/issues/
## or you can buy the paper issues under: http://swag.raspberrypi.org/collections/magpi
## this script is under GNU GENERAL PUBLIC LICENSE
## ------------------------------------------------------------------
#
## VERSION=0.1.2
## USAGE="Usage: sh magpi-issue-downloader.sh [-f firstissue] [-l lastissue]"
#
#Param(
# [string]$f,
# [string]$l
#)
#
## control variables
#$i = 1
#$baseDir = (Split-Path -Path $PSScriptRoot -Parent)
#$issues = Get-Content "$baseDir\sources-for-download\regular-issues.txt" -First 1
#$baseUrl = "https://magpi.raspberrypi.org/issues/"
#$web = New-Object system.net.webclient
#$errorCount = 0
#
## Check if directory dont exist and try create
#if ( -Not (Test-Path -Path "$baseDir\issues" ) ) {
# New-Item -ItemType directory -Path "$baseDir\issues"
#}
#
#
#if ($f) {
# $i = [int]$f
#}
#
#if ($l) {
# $issues = [int]$l
#}
#
#do {
# #start scrapping directory and download files
#
# $tempCounter = if ($i -le 9) { "{0:00}" -f $i } Else { $i }
#
# $fileReponse = ((Invoke-WebRequest -UseBasicParsing "$baseUrl$tempCounter/pdf").Links | Where-Object { $_.href -like "http*" } | Where-Object class -eq c-link)
# if ($fileReponse) {
# try {
# $web.DownloadFile($fileReponse.href, "$baseDir\issues\" + $fileReponse.download)
# Write-Verbose -Message "Downloaded from $fileReponse.href"
# }
# Catch {
# Write-Verbose -Message $_.Exception | format-list -force
# Write-Verbose -Message "Ocorred an error trying download $fileReponse.download"
# $errorCount++
# }
# }
# $i++
#} While ($i -le $issues)
#
#if ($errorCount -gt 0) {
# exit 1
#}

0 comments on commit 895bf9e

Please sign in to comment.