-
-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (116 loc) · 3.56 KB
/
test-workflow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build and Test
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
npm install
- run: |
npm run all
test: # make sure the action works on a clean machine without building
strategy:
matrix:
# os: [ ubuntu-latest, windows-latest, macos-latest ]
os: [ ubuntu-latest ] # only test on ubuntu for now
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Replace in Files - replace string
uses: ./
with:
search-text: '@VERSION@'
files: '**/*.txt'
replacement-text: '1.0.2'
exclude: '**/*.check.txt'
max-parallelism: '1'
- name: Replace in Files - replace using special characters
uses: ./
with:
search-text: '{0}'
files: '**/*.txt'
replacement-text: 'world'
exclude: '**/*.check.txt'
- name: Replace in Files - replace using environment variable
uses: ./
with:
search-text: '_ENV_'
files: '**/*.txt'
replacement-text: ${{ env.REPLACEMENT }}
exclude: '**/*.check.txt'
env:
REPLACEMENT: environment
- name: Replace in Files - pattern finds only one file
uses: ./
with:
search-text: '23'
files: '**/test2.txt'
replacement-text: '42'
exclude: '**/*.check.txt'
- name: Replace in Files - single file
uses: ./
with:
search-text: 'false'
files: 'test-files/test2.txt'
replacement-text: 'true'
exclude: '**/*.check.txt'
- name: Replace in Files - no files matching pattern
uses: ./
with:
search-text: 'foo'
files: '**/*.invalid'
replacement-text: 'bar'
exclude: '**/*.check.txt'
- name: Replace in Files - error on invalid encoding
uses: ./
continue-on-error: true
with:
search-text: 'foo'
files: '**/*.txt'
replacement-text: 'bar'
encoding: 'invalid'
exclude: '**/*.check.txt'
- name: Replace in Files - error on invalid max-parallelism (invalid number)
uses: ./
continue-on-error: true
with:
search-text: 'foo'
files: '**/*.txt'
replacement-text: 'bar'
exclude: '**/*.check.txt'
max-parallelism: '-1'
- name: Replace in Files - error on invalid max-parallelism (invalid string)
uses: ./
continue-on-error: true
with:
search-text: 'foo'
files: '**/*.txt'
replacement-text: 'bar'
exclude: '**/*.check.txt'
max-parallelism: 'invalid'
- name: Verify changes
run: |
echo " > Actual - test1.txt"
cat test-files/test1.txt
echo "=================="
echo " > Expected - test1.txt"
cat test-files/test1.check.txt
echo "=================="
echo " > Actual - test2.txt"
cat test-files/test2.txt
echo "=================="
echo " > Expected - test2.txt"
cat test-files/test2.check.txt
echo "=================="
diff test-files/test1.txt test-files/test1.check.txt >diff1.txt
diff test-files/test2.txt test-files/test2.check.txt >diff2.txt