Skip to content

Commit

Permalink
Update GitHub action tests (#241)
Browse files Browse the repository at this point in the history
* Update GitHub action tests

* Update setup-python action

* Fix cache v2

* Fix cache v3

* Add comment and final test
  • Loading branch information
rezabekf authored Aug 21, 2023
1 parent 0c9b4ee commit d9dacc3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
34 changes: 13 additions & 21 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit Tests
name: pre-commit
on:
push:
branches:
Expand All @@ -9,27 +9,19 @@ on:
- edited
- synchronize
jobs:
unit_tests:
name: Unit tests
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# Cache
- uses: actions/cache@v1
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
# Setup
- name: Set up Python
uses: actions/setup-python@v2
python-version: '3.x'
cache: 'pip' # caching pip dependencies
- run: pip install -r requirements.txt
- uses: actions/cache@v3
env:
cache-name: pre-commit
with:
python-version: '3.10' # have to use quotes due to 0 being removed
- name: Install python packages
run: pip install -Ur requirements.txt

# Run Tests
- name: Run Pre-commit tests
run: pre-commit run --all-files
path: ~/.cache/pre-commit # caching pre-commit environments
key: ${{ env.cache-name }}-${{ hashFiles('.pre-commit-config.yaml','~/.cache/pre-commit/*') }} # the key is to cache both the pre-commit package and dependent hooks
- run: pre-commit run --show-diff-on-failure --color=always --all-files
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pre-commit: $(VENV_NAME)

# Tests
test: $(VENV_NAME)
$(VENV_NAME)/bin/pre-commit run --all-files
$(VENV_NAME)/bin/pre-commit run --show-diff-on-failure --color=always --all-files

lint: $(VENV_NAME)
$(VENV_NAME)/bin/cfn-lint
Expand Down

0 comments on commit d9dacc3

Please sign in to comment.