Skip to content

Commit

Permalink
fix workflow files and add more than 1 attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
siarheidudko committed Jan 31, 2024
1 parent 358cac1 commit 8868f62
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 43 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ jobs:
ref: ${{ github.repository }}
branch: "main"
builds-and-checks: |
npm run lint
npm run build
npm test
# npm test
debug: "true"
ignore-packages: |
@types/node
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ jobs:
run: npm ci
- name: Install builder
run: sudo npm install typescript tslint -g
- name: Run linter
run: npm run lint
- name: Run builder
run: npm run build
- name: Archiving lib directory
Expand Down
70 changes: 34 additions & 36 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,46 +31,44 @@ jobs:
run: npm ci
- name: Install builder
run: sudo npm install typescript tslint -g
- name: Run linter
run: npm run lint
- name: Run builder
run: npm run build
- name: Archiving lib directory
uses: actions/upload-artifact@v3
with:
name: lib
path: ${{ github.workspace }}/lib
test:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: build
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- name: Сheckout repo
uses: actions/checkout@v4
- name: Unarchiving lib directory
uses: actions/download-artifact@v3
with:
name: lib
path: ${{ github.workspace }}/lib
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Run test
run: npm run cov
# test:
# runs-on: ubuntu-latest
# timeout-minutes: 15
# needs: build
# strategy:
# matrix:
# node-version: [16.x, 18.x, 20.x]
# steps:
# - name: Сheckout repo
# uses: actions/checkout@v4
# - name: Unarchiving lib directory
# uses: actions/download-artifact@v3
# with:
# name: lib
# path: ${{ github.workspace }}/lib
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# - name: Cache node modules
# uses: actions/cache@v3
# env:
# cache-name: cache-node-modules
# with:
# path: ~/.npm
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
# - name: Install dependencies
# run: npm ci
# - name: Run test
# run: npm run cov
10 changes: 7 additions & 3 deletions src/methods/createFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ export const createFile = async (
args: { [key: string]: unknown },
size?: { width: number; height: number }
): Promise<ArrayBuffer> => {
let attempt = 5;
let attempt = 1;
let buffer: ArrayBuffer | undefined;
let error: Error | undefined;
while (attempt > 0 && !buffer) {
attempt--;
while (attempt <= 5 && !buffer) {
try {
const res = await axios.post(
`${apiUrl}${type}/${templateType}/${templateId}`,
Expand All @@ -38,6 +37,11 @@ export const createFile = async (
} catch (err: any) {
error = handleError(err);
}
attempt++;
if (!buffer)
await new Promise((res) => {
setTimeout(res, attempt * 1000);
});
}
if (!buffer) throw error;
return buffer;
Expand Down

0 comments on commit 8868f62

Please sign in to comment.