From 250a23bcf82fdb38334872bb944ac8aac4365b3d Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Fri, 15 Sep 2023 22:33:26 +0200 Subject: [PATCH] ci: cache dependencies --- .github/workflows/ci.yml | 46 +++++++++++++++++++++++----------------- ci/test.sh | 14 ------------ 2 files changed, 27 insertions(+), 33 deletions(-) delete mode 100755 ci/test.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2c4c126..6e608620 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,28 +9,36 @@ jobs: matrix: php-versions: - "8.1" -# - "8.2" + - "8.2" steps: - name: Checkout uses: actions/checkout@v4 - name: Install packages run: sudo apt-get install -y jsonlint - - run: find . -type f -name "*.json" | xargs jsonlint-php - -# - name: Install PHP -# uses: shivammathur/setup-php@v2 -# with: -# php-version: ${{ matrix.php-versions }} -# -# - name: Install NPM dependencies -# run: yarn add jsonlint -# -# - name: Lint JSON files -# run: bash ./ci/test.sh -# -# - name: Install Composer dependencies -# run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist -# -# - name: Test conversion of countries data -# run: php countries.php convert + + - name: Lint JSON files + run: find . -type f -name "*.json" | xargs jsonlint-php + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: dom, gettext + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist + + - name: Test conversion of countries data + run: php countries.php convert diff --git a/ci/test.sh b/ci/test.sh deleted file mode 100755 index 46436e98..00000000 --- a/ci/test.sh +++ /dev/null @@ -1,14 +0,0 @@ -function lintAllJSON() { - for f in $1 - do - lintJSON $f - done -} - -function lintJSON() { - echo "--> lint json file $f" - npx jsonlint --quiet --compact $1 -} - -lintAllJSON "*.json" -lintAllJSON "data/*.json"