From f601a401e505b8b5a2ac045cd4ba4c42a27cac57 Mon Sep 17 00:00:00 2001 From: selim13 Date: Sat, 11 Jun 2022 14:00:13 +0300 Subject: [PATCH] test: check compressed files contents --- .github/workflows/test.yml | 16 ++++++++++++---- test/test.sh | 28 +++++++++++++--------------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c729491..d335ba0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,13 +10,21 @@ jobs: strategy: matrix: - node-version: [12.x, 14.x, 16.x] + node-version: [14.x, 16.x, 18.x] steps: - uses: actions/checkout@v2 + + - name: Install brotli + run: sudo apt-get install -y brotli + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: - node-version: ${{ matrix.node-version }} - - run: npm ci - - run: npm test + node-version: ${{ matrix.node-version }} + + - name: Install NPM packages + run: npm ci + + - name: Run tests + run: npm test diff --git a/test/test.sh b/test/test.sh index e15f0e4..543c619 100755 --- a/test/test.sh +++ b/test/test.sh @@ -2,18 +2,16 @@ set -e -[ -f "test/dist/app.js" ] -[ -f "test/dist/app.js.gz" ] -[ -f "test/dist/app.js.br" ] -[ -f "test/dist/app.js.map" ] -[ -f "test/dist/app.js.map.gz" ] -[ -f "test/dist/app.js.map.br" ] -[ -f "test/dist/style.css" ] -[ -f "test/dist/style.css.gz" ] -[ -f "test/dist/style.css.br" ] -[ -f "test/dist/style.css.map" ] -[ -f "test/dist/style.css.map.gz" ] -[ -f "test/dist/style.css.map.br" ] -[ -f "test/dist/images/vector.svg" ] -[ -f "test/dist/images/vector.svg.gz" ] -[ -f "test/dist/images/vector.svg.br" ] \ No newline at end of file +test_file() { + local file="$1" + + [ -f "$file" ] + zcat "$file.gz" > "$file.gz.out" && cmp --silent "$file" "$file.gz.out" + brotli --decompress --stdout "$file.br" > "$file.br.out" && cmp --silent "$file" "$file.br.out" +} + +test_file test/dist/app.js +test_file test/dist/app.js.map +test_file test/dist/style.css +test_file test/dist/style.css.map +test_file test/dist/images/vector.svg \ No newline at end of file