Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
AbitTheGray committed Jun 18, 2024
1 parent 9f91bbc commit 03abc6f
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 1 deletion.
127 changes: 127 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
on: [push]

jobs:
solo:
runs-on: ubuntu-latest
name: solo test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test
id: test
uses: ./
with:
in-directory: test/solo
out-directory: output

- name: Processed languages
shell: bash
run: |
echo ${{ steps.test.outputs.languages }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: solo
path: output/

combined:
runs-on: ubuntu-latest
name: combined test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test
id: test
uses: ./
with:
in-directory: test/combined
out-directory: output

- name: Processed languages
shell: bash
run: |
echo ${{ steps.test.outputs.languages }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: combined
path: output/

dir:
runs-on: ubuntu-latest
name: dir test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test
id: test
uses: ./
with:
in-directory: test/dir
out-directory: output

- name: Processed languages
shell: bash
run: |
echo ${{ steps.test.outputs.languages }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: dir
path: output/

multiple_solo:
runs-on: ubuntu-latest
name: multiple_solo test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test
id: test
uses: ./
with:
in-directory: test/multiple_solo
out-directory: output

- name: Processed languages
shell: bash
run: |
echo ${{ steps.test.outputs.languages }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: multiple_solo
path: output/

multiple_combined:
runs-on: ubuntu-latest
name: multiple_combined test
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Test
id: test
uses: ./
with:
in-directory: test/multiple_combined
out-directory: output

- name: Processed languages
shell: bash
run: |
echo ${{ steps.test.outputs.languages }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: multiple_combined
path: output/
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const outDirectory = core.getInput('out-directory');

try
{
if(!fs.existsSync(outDirectory))
fs.mkdirSync(outDirectory, { recursive: true });

let languages = new Set;
fs.readdirSync(inDirectory, { withFileTypes: true }).forEach(fileInfo => {
if(fileInfo.isDirectory())
Expand All @@ -73,6 +76,8 @@ try
}
});

core.info("languages: " + Array.from(languages).join(','));

let usedLanguages = new Set;
languages.forEach(language => {
let argFile = null;
Expand All @@ -83,10 +88,13 @@ try
if(fs.existsSync(inDirectory + '/' + language)) //TODO and is directory
argDirectory = inDirectory + '/' + language;

const outputJson = processFiles(argFile, argDirectory, outDirectory + '/' + language);
const outputJson = processFiles(argFile, argDirectory, outDirectory + '/' + language + '.json');
if(outputJson !== null)
usedLanguages.add(language);
});

core.info("usedLanguages: " + Array.from(usedLanguages).join(','));

core.setOutput("languages", Array.from(usedLanguages).join(','));
}
catch(error)
Expand Down
3 changes: 3 additions & 0 deletions test/combined/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.name": "English"
}
3 changes: 3 additions & 0 deletions test/combined/en/language.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.description": "English language"
}
3 changes: 3 additions & 0 deletions test/dir/english/language.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.name": "English"
}
3 changes: 3 additions & 0 deletions test/multiple_combined/cs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.name": "Čeština"
}
3 changes: 3 additions & 0 deletions test/multiple_combined/cs/language.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.description": "Český jazyk"
}
3 changes: 3 additions & 0 deletions test/multiple_combined/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.name": "English"
}
3 changes: 3 additions & 0 deletions test/multiple_combined/en/language.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.description": "English language"
}
3 changes: 3 additions & 0 deletions test/multiple_solo/cs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.name": "Čeština"
}
3 changes: 3 additions & 0 deletions test/multiple_solo/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.name": "English"
}
3 changes: 3 additions & 0 deletions test/solo/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"language.name": "English"
}

0 comments on commit 03abc6f

Please sign in to comment.