From ca938e7db3897198e5c987625ce3fa39dc316eba Mon Sep 17 00:00:00 2001 From: Carlos Garcia Jurado Suarez Date: Fri, 1 Dec 2023 15:31:04 -0800 Subject: [PATCH] refactor setup into common action --- .github/actions/deps/action.yaml | 21 +++++++++++++++++++++ .github/workflows/build-documentation.yml | 10 ++-------- .github/workflows/linting.yml | 11 ++--------- .github/workflows/pre-commit-ci.yml | 11 ++--------- .github/workflows/smoke-test.yml | 11 ++--------- .github/workflows/testing-and-coverage.yml | 12 ++---------- .github/workflows/type-checking.yml | 11 ++--------- 7 files changed, 33 insertions(+), 54 deletions(-) create mode 100644 .github/actions/deps/action.yaml diff --git a/.github/actions/deps/action.yaml b/.github/actions/deps/action.yaml new file mode 100644 index 0000000..d38d141 --- /dev/null +++ b/.github/actions/deps/action.yaml @@ -0,0 +1,21 @@ +name: Setup +description: Setup Dependencies for testing +inputs: + python-version: + required: true + description: Python version to install +runs: + using: composite + steps: + - name: Setup Python + uses: actions/setup-python@v4.5.0 + with: + python-version: ${{inputs.python-version}} + - name: Setup pip + shell: sh + run: | + python3 -m ensurepip + python3 -m pip install --upgrade pip + - name: Install project + shell: sh + run: pip install ".[dev,train]" \ No newline at end of file diff --git a/.github/workflows/build-documentation.yml b/.github/workflows/build-documentation.yml index 35e5f72..d5edd81 100644 --- a/.github/workflows/build-documentation.yml +++ b/.github/workflows/build-documentation.yml @@ -20,16 +20,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - name: Setup Dependencies + uses: ./.github/actions/deps with: python-version: '3.10' - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi - pip install . - name: Install notebook requirements run: | sudo apt-get install pandoc diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 37e1a3d..75d2f56 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -18,17 +18,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 + - name: Setup Dependencies + uses: ./.github/actions/deps with: python-version: '3.10' - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Analyze code with linter uses: psf/black@stable with: diff --git a/.github/workflows/pre-commit-ci.yml b/.github/workflows/pre-commit-ci.yml index f996b7f..dc6cdf6 100644 --- a/.github/workflows/pre-commit-ci.yml +++ b/.github/workflows/pre-commit-ci.yml @@ -16,17 +16,10 @@ jobs: - uses: actions/checkout@v3 with: fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v4 + - name: Setup Dependencies + uses: ./.github/actions/deps with: python-version: '3.10' - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev, train] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - uses: pre-commit/action@v3.0.0 with: extra_args: --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 2aec838..ed5b25d 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -24,17 +24,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - name: Setup Dependencies + uses: ./.github/actions/deps with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: List dependencies run: | pip list diff --git a/.github/workflows/testing-and-coverage.yml b/.github/workflows/testing-and-coverage.yml index d10e266..66fcca4 100644 --- a/.github/workflows/testing-and-coverage.yml +++ b/.github/workflows/testing-and-coverage.yml @@ -18,18 +18,10 @@ jobs: python-version: ['3.8', '3.9', '3.10'] steps: - - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - name: Setup Dependencies + uses: ./.github/actions/deps with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev, train] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Run unit tests with pytest run: | python -m pytest tests --cov=autora_doc --cov-report=xml diff --git a/.github/workflows/type-checking.yml b/.github/workflows/type-checking.yml index 414070c..c7393f5 100644 --- a/.github/workflows/type-checking.yml +++ b/.github/workflows/type-checking.yml @@ -22,17 +22,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + - name: Setup Dependencies + uses: ./.github/actions/deps with: python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - pip install . - pip install .[dev,train] - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Analyze code with mypy run: |