Skip to content

Commit

Permalink
ci: fix job needs and add reusable action
Browse files Browse the repository at this point in the history
  • Loading branch information
luislhl committed Jul 12, 2024
1 parent c6908c1 commit 699add6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 49 deletions.
52 changes: 14 additions & 38 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
retention-days: 1
deploy-dev:
runs-on: ubuntu-latest
needs: init, dependencies
needs: [init, dependencies]

if: ${{ needs.init.outputs.environment == 'dev' }}

Expand All @@ -102,12 +102,6 @@ jobs:
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::769498303037:role/ExplorerServiceGitHubActionsRole
- name: Set up Python
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: 3.9
# This step will parse the JSON secret from AWS Secrets Manager into environment variables
- name: Step name
uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
Expand All @@ -117,13 +111,10 @@ jobs:
- name: Check env
run: |
env
- name: Install Python Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
- name: Set up Python and Dependencies
uses: ./.github/workflows/lib/setup-python
with:
python_version: 3.9
- name: Deploy Lambdas Dev
run: |
make deploy-lambdas-ci stage=dev
Expand Down Expand Up @@ -153,7 +144,7 @@ jobs:
rm /home/runner/.docker/config.json
deploy-testnet:
runs-on: ubuntu-latest
needs: init, dependencies
needs: [init, dependencies]

if: ${{ needs.init.outputs.environment == 'testnet' }}

Expand All @@ -166,18 +157,10 @@ jobs:
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::769498303037:role/ExplorerServiceGitHubActionsRole
- name: Set up Python
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
- name: Set up Python and Dependencies
uses: ./.github/workflows/lib/setup-python
with:
python-version: 3.9
- name: Install Python Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
python_version: 3.9
- name: Deploy Lambdas Testnet
run: |
make deploy-lambdas-ci stage=testnet
Expand Down Expand Up @@ -207,7 +190,8 @@ jobs:
rm /home/runner/.docker/config.json
deploy-mainnet:
runs-on: ubuntu-latest
needs: init, dependencies
needs: [init, dependencies]

if: ${{ needs.init.outputs.environment == 'mainnet' }}

steps:
Expand All @@ -219,18 +203,10 @@ jobs:
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::769498303037:role/ExplorerServiceGitHubActionsRole
- name: Set up Python
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
- name: Set up Python and Dependencies
uses: ./.github/workflows/lib/setup-python
with:
python-version: 3.9
- name: Install Python Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
python_version: 3.9
- name: Deploy Lambdas Mainnet
run: |
make deploy-lambdas-ci stage=mainnet
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/lib/setup-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: "Install Python and Dependencies"
description: "Install Python and Dependencies"

inputs:
python_version:
description: "Python version"
required: true

runs:
using: "composite"
steps:
- name: Set up Python
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
with:
python-version: ${{ inputs.python_version }}

- name: Install Python Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
14 changes: 3 additions & 11 deletions .github/workflows/pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,10 @@ jobs:
- name: Checkout to branch
# https://github.com/actions/checkout/releases/tag/v3.5.3
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
- name: Set up Python
# https://github.com/actions/setup-python/releases/tag/v4.7.0
uses: actions/setup-python@61a6322f88396a6271a6ee3565807d608ecaddd1
- name: Set up Python and Dependencies
uses: ./.github/workflows/lib/setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
pip -q --no-input install poetry
poetry install
- name: Linters
run: |
poetry run make check
python_version: ${{ matrix.python-version }}
- name: Run Tests
run: |
poetry run make test
Expand Down

0 comments on commit 699add6

Please sign in to comment.