From 623930e6bb1e9cbcb6175d542268b6658cf89fd0 Mon Sep 17 00:00:00 2001 From: Ay'yaruq Dotharl Date: Tue, 24 Nov 2020 20:08:58 +1100 Subject: [PATCH 1/7] Properly cache for linter+test workflows --- .github/workflows/css-lint.yml | 22 +++++++----- .github/workflows/javascript-lint.yml | 21 +++++++----- .github/workflows/markdown-lint.yml | 22 +++++++----- .github/workflows/python-lint.yml | 48 +++++++++++++-------------- .github/workflows/test.yml | 25 ++++++++------ 5 files changed, 80 insertions(+), 58 deletions(-) diff --git a/.github/workflows/css-lint.yml b/.github/workflows/css-lint.yml index 1dd2d7d07b..64fbe60a42 100644 --- a/.github/workflows/css-lint.yml +++ b/.github/workflows/css-lint.yml @@ -6,10 +6,6 @@ on: - '**/*.css' - '.github/workflows/css-lint.yml' pull_request: - types: - - opened - - reopened - - synchronize paths: - '**/*.css' - '.github/workflows/css-lint.yml' @@ -18,16 +14,26 @@ jobs: stylelint: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v1 - - name: Setup Node - uses: actions/setup-node@v2-beta + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2-beta with: node-version: '12' + + - uses: actions/cache@v2 + id: npm-cache + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Add Custom Problem Matcher run: | echo "::add-matcher::.github/matchers/${{ github.job }}.json" + - name: Install Dependencies + if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm install - name: npm run stylelint diff --git a/.github/workflows/javascript-lint.yml b/.github/workflows/javascript-lint.yml index e989f9c19c..da621d3442 100644 --- a/.github/workflows/javascript-lint.yml +++ b/.github/workflows/javascript-lint.yml @@ -6,10 +6,6 @@ on: - '**/*.js' - '.github/workflows/javascript-lint.yml' pull_request: - types: - - opened - - reopened - - synchronize paths: - '**/*.js' - '.github/workflows/javascript-lint.yml' @@ -18,13 +14,22 @@ jobs: eslint: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v1 - - name: Setup Node - uses: actions/setup-node@v2-beta + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2-beta with: node-version: '12' + + - uses: actions/cache@v2 + id: npm-cache + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Install Dependencies + if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm install - name: npm run lint diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml index 29778bf2eb..8a62b14d6e 100644 --- a/.github/workflows/markdown-lint.yml +++ b/.github/workflows/markdown-lint.yml @@ -6,10 +6,6 @@ on: - '**/*.md' - '.github/workflows/markdown-lint.yml' pull_request: - types: - - opened - - reopened - - synchronize paths: - '**/*.md' - '.github/workflows/markdown-lint.yml' @@ -18,16 +14,26 @@ jobs: markdownlint: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v1 - - name: Setup Node - uses: actions/setup-node@v2-beta + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2-beta with: node-version: '12' + + - uses: actions/cache@v2 + id: npm-cache + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Add Custom Problem Matcher run: | echo "::add-matcher::.github/matchers/${{ github.job }}.json" + - name: Install Dependencies + if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm install - name: npm run markdownlint diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 750239916b..caaba1397e 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -6,10 +6,6 @@ on: - '**/*.py' - '.github/workflows/python-lint.yml' pull_request: - types: - - opened - - reopened - - synchronize paths: - '**/*.py' - '.github/workflows/python-lint.yml' @@ -18,43 +14,45 @@ jobs: black: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v1 - - name: Setup Python - uses: actions/setup-python@v2 + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 with: python-version: '3.7' # Cache pip dependencies # See also: https://github.com/actions/cache/blob/main/examples.md#python---pip - name: Get pip cache dir - id: pip-cache + id: pip-dir run: | echo "::set-output name=dir::$(pip cache dir)" - - name: pip cache - uses: actions/cache@v2 + - uses: actions/cache@v2 + id: pip-cache with: - path: ${{ steps.pip-cache.outputs.dir }} - key: cactbot-pip-${{ hashFiles('**/requirements.txt') }} + path: ${{ steps.pip-dir.outputs.dir }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | - cactbot-pip- + ${{ runner.os }}-pip- - name: Install Dependencies + if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt + - name: black **/*.py --line-length 100 --check --diff run: | black **/*.py --line-length 100 --check --diff + pylint: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v1 - - name: Setup Python - uses: actions/setup-python@v2 + - uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 with: python-version: '3.7' + - name: Add Custom Problem Matcher run: | echo "::add-matcher::.github/matchers/${{ github.job }}.json" @@ -62,21 +60,23 @@ jobs: # Cache pip dependencies # See also: https://github.com/actions/cache/blob/main/examples.md#python---pip - name: Get pip cache dir - id: pip-cache + id: pip-dir run: | echo "::set-output name=dir::$(pip cache dir)" - - name: pip cache - uses: actions/cache@v2 + - uses: actions/cache@v2 + id: pip-cache with: - path: ${{ steps.pip-cache.outputs.dir }} - key: cactbot-pip-${{ hashFiles('**/requirements.txt') }} + path: ${{ steps.pip-dir.outputs.dir }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} restore-keys: | - cactbot-pip- + ${{ runner.os }}-pip- - name: Install Dependencies + if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt + - name: pylint **/*.py --errors-only run: | pylint **/*.py --errors-only diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c3412c62c..349223fa41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,10 +8,6 @@ on: - 'ui/raidboss/**' - '.github/workflows/test.yml' pull_request: - types: - - opened - - reopened - - synchronize paths: - '**/*.js' - '**/*.py' @@ -22,17 +18,26 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Checkout Code - uses: actions/checkout@v1 - - name: Setup Node - uses: actions/setup-node@v2-beta + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2-beta with: node-version: '12' - - name: Setup Python - uses: actions/setup-python@v2 + + - uses: actions/cache@v2 + id: npm-cache + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - uses: actions/setup-python@v2 with: python-version: '3.7' + - name: Install Dependencies + if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm install - name: npm test From b4deb1774fa8d124ed7d6003451f2670b088677d Mon Sep 17 00:00:00 2001 From: Ay'yaruq Dotharl Date: Tue, 24 Nov 2020 20:09:24 +1100 Subject: [PATCH 2/7] Use npm ci in workflows so the cache is actually useful --- .github/workflows/css-lint.yml | 3 ++- .github/workflows/javascript-lint.yml | 3 ++- .github/workflows/markdown-lint.yml | 3 ++- .github/workflows/test.yml | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/css-lint.yml b/.github/workflows/css-lint.yml index 64fbe60a42..d706bdb5d4 100644 --- a/.github/workflows/css-lint.yml +++ b/.github/workflows/css-lint.yml @@ -35,7 +35,8 @@ jobs: - name: Install Dependencies if: steps.npm-cache.outputs.cache-hit != 'true' run: | - npm install + npm ci + - name: npm run stylelint run: | npm run stylelint diff --git a/.github/workflows/javascript-lint.yml b/.github/workflows/javascript-lint.yml index da621d3442..859ee11e9e 100644 --- a/.github/workflows/javascript-lint.yml +++ b/.github/workflows/javascript-lint.yml @@ -31,7 +31,8 @@ jobs: - name: Install Dependencies if: steps.npm-cache.outputs.cache-hit != 'true' run: | - npm install + npm ci + - name: npm run lint run: | npm run lint diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml index 8a62b14d6e..d96b3a0746 100644 --- a/.github/workflows/markdown-lint.yml +++ b/.github/workflows/markdown-lint.yml @@ -35,7 +35,8 @@ jobs: - name: Install Dependencies if: steps.npm-cache.outputs.cache-hit != 'true' run: | - npm install + npm ci + - name: npm run markdownlint run: | npm run markdownlint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 349223fa41..67ba48c7ca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,7 +39,8 @@ jobs: - name: Install Dependencies if: steps.npm-cache.outputs.cache-hit != 'true' run: | - npm install + npm ci + - name: npm test run: | npm test From 271fc127811d07b7d0b449551f9450641260fc1d Mon Sep 17 00:00:00 2001 From: Ay'yaruq Dotharl Date: Wed, 25 Nov 2020 12:36:27 +1100 Subject: [PATCH 3/7] Revert to older checkout action --- .github/workflows/css-lint.yml | 2 +- .github/workflows/javascript-lint.yml | 2 +- .github/workflows/markdown-lint.yml | 2 +- .github/workflows/python-lint.yml | 4 ++-- .github/workflows/test.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/css-lint.yml b/.github/workflows/css-lint.yml index d706bdb5d4..fdc7124e89 100644 --- a/.github/workflows/css-lint.yml +++ b/.github/workflows/css-lint.yml @@ -14,7 +14,7 @@ jobs: stylelint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions/setup-node@v2-beta with: diff --git a/.github/workflows/javascript-lint.yml b/.github/workflows/javascript-lint.yml index 859ee11e9e..4f8fd44d9b 100644 --- a/.github/workflows/javascript-lint.yml +++ b/.github/workflows/javascript-lint.yml @@ -14,7 +14,7 @@ jobs: eslint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions/setup-node@v2-beta with: diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml index d96b3a0746..0754d25847 100644 --- a/.github/workflows/markdown-lint.yml +++ b/.github/workflows/markdown-lint.yml @@ -14,7 +14,7 @@ jobs: markdownlint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions/setup-node@v2-beta with: diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index caaba1397e..8818188a20 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -14,7 +14,7 @@ jobs: black: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions/setup-python@v2 with: @@ -47,7 +47,7 @@ jobs: pylint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions/setup-python@v2 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67ba48c7ca..b3a97d8cbe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,7 +18,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions/setup-node@v2-beta with: From 0527647a09d12dfe06473572442884398e947fcf Mon Sep 17 00:00:00 2001 From: Ay'yaruq Dotharl Date: Wed, 25 Nov 2020 13:02:25 +1100 Subject: [PATCH 4/7] Minor spacing adjustment in requirements.txt to intentionally purge cache --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index c2ab8a91d5..48cf65bba1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # Linting, formatting black==19.10b0 pylint==2.5.3 + # dependencies for utils/*.py PyYAML requests From 67067d5efca960eddacdce858d65361120728e2f Mon Sep 17 00:00:00 2001 From: Ay'yaruq Dotharl Date: Wed, 25 Nov 2020 13:12:09 +1100 Subject: [PATCH 5/7] Rely on package managers being smart due to bug in cache restoration upstream --- .github/workflows/css-lint.yml | 2 -- .github/workflows/javascript-lint.yml | 2 -- .github/workflows/markdown-lint.yml | 2 -- .github/workflows/python-lint.yml | 4 ---- .github/workflows/test.yml | 2 -- 5 files changed, 12 deletions(-) diff --git a/.github/workflows/css-lint.yml b/.github/workflows/css-lint.yml index fdc7124e89..8f240ded1c 100644 --- a/.github/workflows/css-lint.yml +++ b/.github/workflows/css-lint.yml @@ -21,7 +21,6 @@ jobs: node-version: '12' - uses: actions/cache@v2 - id: npm-cache with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -33,7 +32,6 @@ jobs: echo "::add-matcher::.github/matchers/${{ github.job }}.json" - name: Install Dependencies - if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm ci diff --git a/.github/workflows/javascript-lint.yml b/.github/workflows/javascript-lint.yml index 4f8fd44d9b..4b4d5c82a5 100644 --- a/.github/workflows/javascript-lint.yml +++ b/.github/workflows/javascript-lint.yml @@ -21,7 +21,6 @@ jobs: node-version: '12' - uses: actions/cache@v2 - id: npm-cache with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -29,7 +28,6 @@ jobs: ${{ runner.os }}-node- - name: Install Dependencies - if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm ci diff --git a/.github/workflows/markdown-lint.yml b/.github/workflows/markdown-lint.yml index 0754d25847..e3b0e66b26 100644 --- a/.github/workflows/markdown-lint.yml +++ b/.github/workflows/markdown-lint.yml @@ -21,7 +21,6 @@ jobs: node-version: '12' - uses: actions/cache@v2 - id: npm-cache with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -33,7 +32,6 @@ jobs: echo "::add-matcher::.github/matchers/${{ github.job }}.json" - name: Install Dependencies - if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm ci diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index 8818188a20..b5fd8d555e 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -28,7 +28,6 @@ jobs: echo "::set-output name=dir::$(pip cache dir)" - uses: actions/cache@v2 - id: pip-cache with: path: ${{ steps.pip-dir.outputs.dir }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} @@ -36,7 +35,6 @@ jobs: ${{ runner.os }}-pip- - name: Install Dependencies - if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt @@ -65,7 +63,6 @@ jobs: echo "::set-output name=dir::$(pip cache dir)" - uses: actions/cache@v2 - id: pip-cache with: path: ${{ steps.pip-dir.outputs.dir }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} @@ -73,7 +70,6 @@ jobs: ${{ runner.os }}-pip- - name: Install Dependencies - if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b3a97d8cbe..1757ca958f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,7 +25,6 @@ jobs: node-version: '12' - uses: actions/cache@v2 - id: npm-cache with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} @@ -37,7 +36,6 @@ jobs: python-version: '3.7' - name: Install Dependencies - if: steps.npm-cache.outputs.cache-hit != 'true' run: | npm ci From d5e532f3068f4c66c3235ac15eb66f5be2ba9fda Mon Sep 17 00:00:00 2001 From: Ay'yaruq Dotharl Date: Thu, 3 Dec 2020 18:18:44 +1100 Subject: [PATCH 6/7] Conditionally cache python deps --- .github/workflows/python-lint.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index b5fd8d555e..8818188a20 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -28,6 +28,7 @@ jobs: echo "::set-output name=dir::$(pip cache dir)" - uses: actions/cache@v2 + id: pip-cache with: path: ${{ steps.pip-dir.outputs.dir }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} @@ -35,6 +36,7 @@ jobs: ${{ runner.os }}-pip- - name: Install Dependencies + if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt @@ -63,6 +65,7 @@ jobs: echo "::set-output name=dir::$(pip cache dir)" - uses: actions/cache@v2 + id: pip-cache with: path: ${{ steps.pip-dir.outputs.dir }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} @@ -70,6 +73,7 @@ jobs: ${{ runner.os }}-pip- - name: Install Dependencies + if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt From eb7fc578a8748f41cbbc1532ad9377f0a8106633 Mon Sep 17 00:00:00 2001 From: Ay'yaruq Dotharl Date: Fri, 4 Dec 2020 12:18:40 +1100 Subject: [PATCH 7/7] Revert "Conditionally cache python deps" This reverts commit d5e532f3068f4c66c3235ac15eb66f5be2ba9fda. --- .github/workflows/python-lint.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/python-lint.yml b/.github/workflows/python-lint.yml index cd3c28d2ee..419a738e9b 100644 --- a/.github/workflows/python-lint.yml +++ b/.github/workflows/python-lint.yml @@ -30,7 +30,6 @@ jobs: echo "::set-output name=dir::$(pip cache dir)" - uses: actions/cache@v2 - id: pip-cache with: path: ${{ steps.pip-dir.outputs.dir }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} @@ -38,7 +37,6 @@ jobs: ${{ runner.os }}-pip- - name: Install Dependencies - if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt @@ -67,7 +65,6 @@ jobs: echo "::set-output name=dir::$(pip cache dir)" - uses: actions/cache@v2 - id: pip-cache with: path: ${{ steps.pip-dir.outputs.dir }} key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} @@ -75,7 +72,6 @@ jobs: ${{ runner.os }}-pip- - name: Install Dependencies - if: steps.pip-cache.outputs.cache-hit != 'true' run: | pip install -r requirements.txt