Skip to content

Commit 9d51177

Browse files
committed
test test
1 parent da07d46 commit 9d51177

File tree

3 files changed

+70
-76
lines changed

3 files changed

+70
-76
lines changed

.github/workflows/test-core.yml

+19-11
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@ name: Test Core
22

33
on:
44
workflow_call:
5-
#inputs:
6-
#main-repo:
7-
#required: true
8-
#type: boolean
9-
#fix-404:
10-
#required: true
11-
#type: boolean
5+
inputs:
6+
mock-repo:
7+
required: false
8+
type: string
9+
main-repo:
10+
required: true
11+
type: boolean
12+
with-404:
13+
required: true
14+
type: boolean
1215

1316
jobs:
1417
test:
1518
runs-on: ubuntu-latest
1619
steps:
20+
- name: Override GITHUB_REPOSITORY
21+
if: ${{ inputs.mock-repo }}
22+
run: |
23+
echo "Simulating a different repository"
24+
echo "GITHUB_REPOSITORY=${{ inputs.mock-repo }}" >> $GITHUB_ENV
1725
- name: Checkout
1826
uses: actions/checkout@v4
1927
- name: Setup .NET
@@ -24,8 +32,8 @@ jobs:
2432
uses: ./
2533
with:
2634
project-path: Test/Test.csproj
27-
#main-repo: ${{ inputs.main-repo }}
28-
#fix-404: ${{ inputs.fix-404 }}
35+
- name: Delete 404
36+
if: ${{ inputs.with-404 == false }}
37+
run: rm -f _out/wwwroot/404.html
2938
- name: Verify
30-
#run: Test/Verify.sh --main-repo=${{ inputs.main-repo }} --fix-404=${{ inputs.fix-404 }} ${{ github.event.repository.name }}
31-
run: Test/Verify.sh ${{ github.event.repository.name }}
39+
run: Test/Verify.sh --main-repo=${{ inputs.main-repo }} ${{ github.event.repository.name }}

.github/workflows/test.yml

+21-22
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,28 @@ on:
77
branches: ["main"]
88

99
jobs:
10-
#test-non-main-repo-fix-404:
11-
#uses: ./.github/workflows/test-core.yml
12-
#with:
13-
#main-repo: false
14-
#fix-404: true
15-
16-
#test-main-repo-fix-404:
17-
#uses: ./.github/workflows/test-core.yml
18-
#with:
19-
#main-repo: true
20-
#fix-404: true
10+
test-non-main-repo-with-404:
11+
uses: ./.github/workflows/test-core.yml
12+
with:
13+
main-repo: false
14+
with-404: true
2115

22-
#test-non-main-repo-no-fix-404:
23-
#uses: ./.github/workflows/test-core.yml
24-
#with:
25-
#main-repo: false
26-
#fix-404: false
16+
test-main-repo-with-404:
17+
uses: ./.github/workflows/test-core.yml
18+
with:
19+
mock-repo: na1307/na1307.github.io
20+
main-repo: true
21+
with-404: true
2722

28-
#test-main-repo-no-fix-404:
29-
#uses: ./.github/workflows/test-core.yml
30-
#with:
31-
#main-repo: true
32-
#fix-404: false
23+
test-non-main-repo-without-404:
24+
uses: ./.github/workflows/test-core.yml
25+
with:
26+
main-repo: false
27+
with-404: false
3328

34-
test:
29+
test-main-repo-without-404:
3530
uses: ./.github/workflows/test-core.yml
31+
with:
32+
mock-repo: na1307/na1307.github.io
33+
main-repo: true
34+
with-404: false

Test/Verify.sh

+30-43
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,37 @@
11
#!/usr/bin/bash
22

3-
#if [ $1 == "--main-repo=false" ]; then
4-
# MAINREPO=false;
5-
#elif [ $1 == "--main-repo=true" ]; then
6-
# MAINREPO=true;
7-
#else
8-
# echo Unknown Argument.
9-
# exit 1
10-
#fi
11-
12-
#if [ $2 == "--fix-404=false" ]; then
13-
# FIX404=false;
14-
#elif [ $2 == "--fix-404=true" ]; then
15-
# FIX404=true;
16-
#else
17-
# echo Unknown Argument.
18-
# exit 1
19-
#fi
20-
21-
#if [ ! -f _out/wwwroot/.nojekyll ]; then
22-
# echo ".nojekyll doesn't exist!"
23-
# exit 1
24-
#fi
25-
26-
#if [ $MAINREPO == true ]; then
27-
# grep -i 'base href="/"' _out/wwwroot/index.html > /dev/null
28-
#else
29-
# grep -i "base href=\"/$3/\"" _out/wwwroot/index.html > /dev/null
30-
#fi
31-
32-
#if [ $MAINREPO == false ] && [ $FIX404 == true ]; then
33-
# grep -i "/$3/?p=/" _out/wwwroot/404.html > /dev/null
34-
#else
35-
# ! grep -i "/$3/?p=/" _out/wwwroot/404.html > /dev/null
36-
#fi
37-
38-
grep -i "base href=\"/$1/\"" _out/wwwroot/index.html > /dev/null
39-
40-
if [ $? -ne 0 ]; then
41-
echo index.html verify failed.
3+
verifyExitCode() {
4+
if [ $2 -eq 0 ]; then
5+
echo $1 verify passed.
6+
else
7+
echo $1 verify failed.
8+
exit 1
9+
fi
10+
}
11+
12+
if [ $1 == "--main-repo=false" ]; then
13+
MAINREPO=false;
14+
elif [ $1 == "--main-repo=true" ]; then
15+
MAINREPO=true;
16+
else
17+
echo Unknown Argument.
4218
exit 1
4319
fi
4420

45-
grep -i "/$1/?p=/" _out/wwwroot/404.html > /dev/null
21+
if [ $MAINREPO == true ]; then
22+
grep -i 'base href="/"' _out/wwwroot/index.html > /dev/null
23+
verifyExitCode index $?
24+
else
25+
grep -i "base href=\"/$2/\"" _out/wwwroot/index.html > /dev/null
26+
verifyExitCode index $?
27+
fi
4628

47-
if [ $? -ne 0 ]; then
48-
echo 404.html verify failed.
49-
exit 1
29+
if [ -e _out/wwwroot/404.html ]; then
30+
if [ $MAINREPO == true ]; then
31+
grep -i "/?p=/" _out/wwwroot/404.html > /dev/null
32+
verifyExitCode 404 $?
33+
elif [ $MAINREPO == false ]; then
34+
grep -i "/$2/?p=/" _out/wwwroot/404.html > /dev/null
35+
verifyExitCode 404 $?
36+
fi
5037
fi

0 commit comments

Comments
 (0)