Skip to content

Commit

Permalink
added actions yaml files (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeleehen authored Dec 17, 2024
1 parent 44cfa19 commit b6ab779
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Docker Image CI

on:
push:
branches: [ "main" ]
tags: [ "*.*.*" ]
pull_request:
branches: [ "main" ]

jobs:

build-calculate-pi:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: joeleehen/pubscraper
flavor: latest=true
tags: |
type=ref, event=branch
type=ref, event=pr
type=semver, pattern={{version}}
- name: Login to DockerHub
if: github.ref_type == 'tag'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max

- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
40 changes: 40 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Python unit test

on:
push:
workflow_dispatch:

jobs:

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-in-project: false
virtualenvs-path: ~/.virtualenvs

- name: Cache Poetry virtualenv
uses: actions/cache@v3
id: cache
with:
path: ~/.virtualenvs
key: poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
poetry-${{ hashFiles('**/poetry.lock') }}
- name: Install Dependencies
run: poetry install
if: steps.cache.outputs.cache-hit != 'true'

- name: Test with pytest
run: poetry run pytest

0 comments on commit b6ab779

Please sign in to comment.