Skip to content

style: Fix typos and add codespell pre-commit hook #624

style: Fix typos and add codespell pre-commit hook

style: Fix typos and add codespell pre-commit hook #624

Workflow file for this run

name: ci
on:
push:
branches: [main, develop]
pull_request_target:
types: [assigned, opened, synchronize, reopened]
env:
REGISTRY: ghcr.io
jobs:
setup:
runs-on: ubuntu-latest
outputs:
ci_name_ref_slug: ${{ steps.set_env.outputs.ci_name_ref_slug }}
image_name: ${{ steps.set_env.outputs.image_name }}
steps:
- uses: FranzDiebold/github-env-vars-action@v2
- name: Generate global env vars
id: set_env
run: |
echo "::set-output name=ci_name_ref_slug::$CI_REF_NAME_SLUG"
echo "::set-output name=image_name::$REGISTRY/$CI_REPOSITORY_OWNER_SLUG/$CI_REPOSITORY_NAME_SLUG"
build:
needs: [setup]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
if: ${{ github.event_name == 'push' }}
- name: Checkout
uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ needs.setup.outputs.image_name }}
# - name: Build and push Docker image
# uses: docker/build-push-action@v3
# with:
# context: .
# file: dev.Dockerfile
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
- name: Build and push test Docker image
uses: docker/build-push-action@v4
with:
context: .
file: dev.Dockerfile
push: true
target: test-image
tags: "${{ needs.setup.outputs.image_name }}/test:${{ github.sha }},${{ needs.setup.outputs.image_name }}/test:${{ needs.setup.outputs.ci_name_ref_slug }}"
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push tool Docker image
uses: docker/build-push-action@v4
with:
context: .
file: tool.Dockerfile
push: true
tags: "${{ needs.setup.outputs.image_name }}/tool:${{ github.sha }},${{ needs.setup.outputs.image_name }}/tool:${{ needs.setup.outputs.ci_name_ref_slug }}"
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
style:
needs: [build]
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/qdax/tool:${{ github.sha }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
if: ${{ github.event_name == 'push' }}
- name: Checkout
uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Run pre-commits
run: |
git config --global --add safe.directory $GITHUB_WORKSPACE
pre-commit run --all-files
tests:
needs: [build]
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository_owner }}/qdax/test:${{ github.sha }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v3
if: ${{ github.event_name == 'push' }}
- name: Checkout
uses: actions/checkout@v3
if: ${{ github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Run pytests
run: |
coverage run -m pytest -vv tests
coverage xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2