Skip to content

Commit 99a94bb

Browse files
committed
CI: Add extra absolute path test, and number tests.
1 parent ab2f4d5 commit 99a94bb

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

.github/workflows/action-test.yml

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
- run: npm install
1212
- run: npm run lint
1313
- run: npm run package
14+
1415
action-test:
1516
runs-on: ${{ matrix.os }}
1617
strategy:
@@ -30,146 +31,148 @@ jobs:
3031
if: steps.no-param-file-url == 'success'
3132
run: exit 1
3233

33-
- name: Simple test to download a file
34+
- name: 010 - Simple test to download a file
3435
uses: ./
3536
id: download-poetry-simple
3637
with:
3738
file-url: 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py'
3839
- run: echo "The file was downloaded to ${{ steps.download-poetry-simple.outputs.file-path }}"
39-
- name: Test file exists
40+
- name: 010 - Test file exists
4041
run: python -c "import os; exit(not os.path.isfile('get-poetry.py'))"
41-
- name: Test action output path is correct
42+
- name: 010 - Test action output path is correct
4243
run: python -c "import os; exit(not r'${{ steps.download-poetry-simple.outputs.file-path }}' == os.path.abspath('get-poetry.py'))"
4344
- run: ls && rm ${{ steps.download-poetry-simple.outputs.file-path }} && ls
4445

45-
- name: Test to download a file with a different filename
46+
- name: 020 - Test to download a file with a different filename
4647
uses: ./
4748
id: download-poetry-name
4849
with:
4950
file-url: 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py'
5051
file-name: 'new_name.py'
5152
- run: echo "The file was downloaded to ${{ steps.download-poetry-name.outputs.file-path }}"
52-
- name: Test file exists
53+
- name: 020 - Test file exists
5354
run: python -c "import os; exit(not os.path.isfile('new_name.py'))"
54-
- name: Test action output path is correct
55+
- name: 020 - Test action output path is correct
5556
run: python -c "import os; exit(not r'${{ steps.download-poetry-name.outputs.file-path }}' == os.path.abspath('new_name.py'))"
5657
- run: ls && rm ${{ steps.download-poetry-name.outputs.file-path }} && ls
5758

58-
- name: Test to download a file to a different path
59+
- name: 030 - Test to download a file to a different path
5960
uses: ./
6061
id: download-poetry-location
6162
with:
6263
file-url: 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py'
6364
location: 'new_folder'
6465
- run: echo "The file was downloaded to ${{ steps.download-poetry-location.outputs.file-path }}"
65-
- name: Test file exists
66+
- name: 030 - Test file exists
6667
run: python -c "import os; exit(not os.path.isfile('new_folder/get-poetry.py'))"
67-
- name: Test action output path is correct
68+
- name: 030 - Test action output path is correct
6869
run: python -c "import os; exit(not r'${{ steps.download-poetry-location.outputs.file-path }}' == os.path.abspath('new_folder/get-poetry.py'))"
69-
- run: ls new_folder && rm -r new_folder
70+
- run: ls && ls new_folder && rm -r new_folder && ls
7071

71-
- name: Test to download a file to a relative path
72+
- name: 040 - Test to download a file to a relative path
7273
uses: ./
7374
id: download-poetry-relative
7475
with:
7576
file-url: 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py'
7677
location: '../'
7778
- run: echo "The file was downloaded to ${{ steps.download-poetry-relative.outputs.file-path }}"
78-
- name: Test file exists
79+
- name: 040 - Test file exists
7980
run: python -c "import os; exit(not os.path.isfile('../get-poetry.py'))"
80-
- name: Test action output path is correct
81+
- name: 040 - Test action output path is correct
8182
run: python -c "import os; exit(not r'${{ steps.download-poetry-relative.outputs.file-path }}' == os.path.abspath('../get-poetry.py'))"
8283
- run: ls ../ && rm ${{ steps.download-poetry-relative.outputs.file-path }} && ls ../
8384

84-
- name: Test to download a file to an absolute path
85+
- name: 050 - Test to download a file to an absolute path
8586
uses: ./
8687
id: download-poetry-absolute
8788
with:
8889
file-url: 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py'
8990
location: '${{ github.workspace }}/a_folder'
9091
- run: echo "The file was downloaded to ${{ steps.download-poetry-absolute.outputs.file-path }}"
91-
- name: Test file exists
92+
- name: 050 - Test file exists
9293
run: python -c "import os; exit(not os.path.isfile(r'${{ github.workspace }}/a_folder/get-poetry.py'))"
93-
- name: Test action output path is correct
94+
- name: 050 - Test action output path is correct
9495
run: python -c "import os; exit(not r'${{ steps.download-poetry-absolute.outputs.file-path }}' == os.path.abspath(r'${{ github.workspace }}/a_folder/get-poetry.py'))"
95-
- run: ls ${{ github.workspace }}/a_folder && rm -r ${{ github.workspace }}/a_folder
96+
- run: ls ${{ github.workspace }} && ls ${{ github.workspace }}/a_folder && rm -r ${{ github.workspace }}/a_folder && ls ${{ github.workspace }}
9697

97-
- name: Test to download a file to a different filename and path
98+
- name: 060 - Test to download a file to a different filename and path
9899
uses: ./
99100
id: download-poetry-both
100101
with:
101102
file-url: 'https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py'
102103
location: 'different_folder'
103104
file-name: 'new_name.py'
104105
- run: echo "The file was downloaded to ${{ steps.download-poetry-both.outputs.file-path }}"
105-
- name: Test file exists
106+
- name: 060 - Test file exists
106107
run: python -c "import os; exit(not os.path.isfile('different_folder/new_name.py'))"
108+
- name: 060 - Test action output path is correct
109+
run: python -c "import os; exit(not r'${{ steps.download-poetry-both.outputs.file-path }}' == os.path.abspath('different_folder/new_name.py'))"
107110
- run: ls different_folder && rm -r different_folder
108111

109-
- name: Test to download a file and match MD5 in lowercase
112+
- name: 070 - Test to download a file and match MD5 in lowercase
110113
uses: ./
111114
id: download-tar-md5
112115
with:
113116
file-url: 'https://github.com/carlosperate/download-file-action/archive/refs/tags/v1.0.3.tar.gz'
114117
file-name: 'name_md5.tar.gz'
115118
md5: 'e3b51204dedc75588ca164a26b51610d'
116-
- name: Test file exists
119+
- name: 070 - Test file exists
117120
run: python -c "import os, sys; sys.exit(not os.path.isfile('name_md5.tar.gz'))"
118121
- run: rm name_md5.tar.gz
119122

120-
- name: Test to download a file and match MD5 in UPPERCASE
123+
- name: 080 - Test to download a file and match MD5 in UPPERCASE
121124
uses: ./
122125
id: download-tar-md5-uppercase
123126
with:
124127
file-url: 'https://github.com/carlosperate/download-file-action/archive/refs/tags/v1.0.3.tar.gz'
125128
file-name: 'name_md5.tar.gz'
126129
md5: 'E3B51204DEDC75588CA164A26B51610D'
127-
- name: Test file exists
130+
- name: 080 - Test file exists
128131
run: python -c "import os, sys; sys.exit(not os.path.isfile('name_md5.tar.gz'))"
129132
- run: rm name_md5.tar.gz
130133

131-
- name: Test bad MD5 value
134+
- name: 090 - Test bad MD5 value
132135
continue-on-error: true
133136
uses: ./
134137
id: download-tar-md5-bad
135138
with:
136139
file-url: 'https://github.com/carlosperate/download-file-action/archive/refs/tags/v1.0.3.tar.gz'
137140
md5: '12345678901234567890123456789012'
138-
- name: Fail workflow if bad MD5 test didn't raise an error
141+
- name: 090 - Fail workflow if bad MD5 test didn't raise an error
139142
if: steps.download-tar-md5-bad.outcome == 'success'
140143
run: exit 1
141144
- run: rm download-file-action-1.0.3.tar.gz
142145

143-
- name: Test to download a file and match SHA256 in lowercase
146+
- name: 100 - Test to download a file and match SHA256 in lowercase
144147
uses: ./
145148
id: download-tar-sha256
146149
with:
147150
file-url: 'https://github.com/carlosperate/download-file-action/archive/refs/tags/v1.0.3.tar.gz'
148151
file-name: 'name_sha256.tar.gz'
149152
sha256: '76ef5cf6e910a4955f713fb36cca6f90ffeee6ffafe743754716e149d68136de'
150-
- name: Test file exists
153+
- name: 100 - Test file exists
151154
run: python -c "import os, sys; sys.exit(not os.path.isfile('name_sha256.tar.gz'))"
152155
- run: rm name_sha256.tar.gz
153156

154-
- name: Test to download a file and match SHA256 in UPPERCASE
157+
- name: 110 - Test to download a file and match SHA256 in UPPERCASE
155158
uses: ./
156159
id: download-tar-sha256-uppercase
157160
with:
158161
file-url: 'https://github.com/carlosperate/download-file-action/archive/refs/tags/v1.0.3.tar.gz'
159-
file-name: 'name_sha256.tar.gz'
162+
file-name: 'name_sha256_upper.tar.gz'
160163
sha256: '76EF5CF6E910A4955F713FB36CCA6F90FFEEE6FFAFE743754716E149D68136DE'
161-
- name: Test file exists
162-
run: python -c "import os, sys; sys.exit(not os.path.isfile('name_sha256.tar.gz'))"
163-
- run: rm name_sha256.tar.gz
164+
- name: 110 - Test file exists
165+
run: python -c "import os, sys; sys.exit(not os.path.isfile('name_sha256_upper.tar.gz'))"
166+
- run: rm name_sha256_upper.tar.gz
164167

165-
- name: Test bad SHA256 value
168+
- name: 120 - Test bad SHA256 value
166169
continue-on-error: true
167170
uses: ./
168171
id: download-tar-sha256-bad
169172
with:
170173
file-url: 'https://github.com/carlosperate/download-file-action/archive/refs/tags/v1.0.3.tar.gz'
171174
sha256: '1234567890123456789012345678901234567890123456789012345678901234'
172-
- name: Fail workflow if bad SHA256 test didn't raise an error
175+
- name: 120 - Fail workflow if bad SHA256 test didn't raise an error
173176
if: steps.download-tar-sha256-bad.outcome == 'success'
174177
run: exit 1
175178
- run: rm download-file-action-1.0.3.tar.gz

0 commit comments

Comments
 (0)