From 251a79377e19f439cde2bcb79bfe366b13dc1a8e Mon Sep 17 00:00:00 2001 From: ktro2828 Date: Tue, 1 Oct 2024 09:13:32 +0900 Subject: [PATCH] chore: add github actions Signed-off-by: ktro2828 --- .github/workflows/build-and-test.yaml | 38 +++++++++++++++++++ .../workflows/cancel-previous-workflows.yaml | 15 ++++++++ .github/workflows/deploy-document.yaml | 19 ++++++++++ 3 files changed, 72 insertions(+) create mode 100644 .github/workflows/build-and-test.yaml create mode 100644 .github/workflows/cancel-previous-workflows.yaml create mode 100644 .github/workflows/deploy-document.yaml diff --git a/.github/workflows/build-and-test.yaml b/.github/workflows/build-and-test.yaml new file mode 100644 index 0000000..e4f1feb --- /dev/null +++ b/.github/workflows/build-and-test.yaml @@ -0,0 +1,38 @@ +name: build-and-test + +on: + push: + branches: [main] + pull_request: + types: [opened, synchronize] + paths: + - "**" + - "!docs/**" + - "!README.md" + - "!.github/**" + - .github/workflows/build-and-test.yaml + workflow_dispatch: + +jobs: + build-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10", "3.12"] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + python-version-file: "pyproject.toml" + cache: "poetry" + + - name: Install dependencies + run: poetry install + + - name: Run tests + run: poetry run pytest diff --git a/.github/workflows/cancel-previous-workflows.yaml b/.github/workflows/cancel-previous-workflows.yaml new file mode 100644 index 0000000..23d282f --- /dev/null +++ b/.github/workflows/cancel-previous-workflows.yaml @@ -0,0 +1,15 @@ +name: cancel-previous-workflows + +on: + pull_request_target: + +jobs: + cancel-previous-workflows: + runs-on: ubuntu-latest + timeout-minutes: 1 + steps: + - name: Cancel previous runs + uses: styfle/cancel-workflow-action@0.12.1 + with: + workflow_id: all + all_but_latest: true \ No newline at end of file diff --git a/.github/workflows/deploy-document.yaml b/.github/workflows/deploy-document.yaml new file mode 100644 index 0000000..23a4c91 --- /dev/null +++ b/.github/workflows/deploy-document.yaml @@ -0,0 +1,19 @@ +name: deploy-document + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + deplot-document: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + python-version-file: "pyproject.toml" + cache: "poetry" + - run: poetry install + - run: poetry run mkdocs gh-deploy --force \ No newline at end of file