From 16c78a800fab5f5316513953062bb2ef2cb21878 Mon Sep 17 00:00:00 2001 From: Edward Jones Date: Fri, 8 Nov 2024 10:47:12 +0000 Subject: [PATCH] Preparation for github actions --- .github/workflows/main.yml | 132 --------------------------- .github/workflows/publish-docker.yml | 56 ++++++++++++ .github/workflows/publish-pages.yml | 51 +++++++++++ .github/workflows/python-publish.yml | 2 - .github/workflows/test-and-lint.yml | 42 +++++++++ .gitignore | 1 + README.md | 6 +- pyproject.toml | 6 +- 8 files changed, 155 insertions(+), 141 deletions(-) delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/publish-docker.yml create mode 100644 .github/workflows/publish-pages.yml create mode 100644 .github/workflows/test-and-lint.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 123cea4..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,132 +0,0 @@ - -name: CI Pipeline - -on: - push: - branches: - - main - pull_request: - branches: - - main - -jobs: - docker: - runs-on: ubuntu-latest - name: Docker Build and Push - if: github.event_name != 'pull_request' - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to Docker Hub - env: - DOCKER_REGISTRY_USER: ${{ secrets.CI_REGISTRY_USER }} - DOCKER_REGISTRY_PASSWORD: ${{ secrets.CI_REGISTRY_PASSWORD }} - run: echo "${DOCKER_REGISTRY_PASSWORD}" | docker login -u "${DOCKER_REGISTRY_USER}" --password-stdin - - - name: Build and push Docker image - run: | - export IMAGE_NAME=${{ secrets.CI_REGISTRY_IMAGE }} - docker build -t $IMAGE_NAME:${{ github.ref_name }} . - docker push $IMAGE_NAME:${{ github.ref_name }} - env: - DOCKER_BASE: ${{ secrets.DOCKER_BASE }} - - test: - runs-on: ubuntu-latest - name: Run Tests - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install pytest coverage - - - name: Run pytest - run: | - pytest --cov=martepy --cov-report=term --cov-report=html:cov_html --cov-fail-under=90 - - name: Upload Coverage Report - uses: actions/upload-artifact@v2 - with: - name: coverage-report - path: cov_html/ - retention-days: 30 - - linting: - runs-on: ubuntu-latest - name: Code Linting - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: Install pylint - run: pip install pylint - - - name: Run pylint - run: pylint martepy - - docs: - runs-on: ubuntu-latest - name: Build Documentation - if: github.ref == 'refs/heads/main' - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: Install dependencies - run: | - pip install -r requirements.txt - pip install sphinx - - - name: Build HTML docs - run: | - cd docs - make html - - - name: Upload Documentation - uses: actions/upload-artifact@v2 - with: - name: documentation - path: docs/build/html - retention-days: 7 - - pages: - runs-on: ubuntu-latest - name: Deploy Documentation to Pages - if: github.ref == 'refs/heads/main' - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Copy documentation to public folder - run: | - mkdir -p public - rm -rf public/* - cp -a docs/build/html/* public/ - - - name: Upload Pages Artifact - uses: actions/upload-artifact@v2 - with: - name: pages - path: public/ - retention-days: 365 \ No newline at end of file diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 0000000..8583c01 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,56 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish Docker image + +on: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: my-docker-hub-namespace/my-docker-hub-repository + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true \ No newline at end of file diff --git a/.github/workflows/publish-pages.yml b/.github/workflows/publish-pages.yml new file mode 100644 index 0000000..f058f2f --- /dev/null +++ b/.github/workflows/publish-pages.yml @@ -0,0 +1,51 @@ +# +name: Deploy sphinx site to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: [$default-branch] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + + build: + runs-on: ubuntu-latest + container: + image: sudilav1/martepy:latest + steps: + - name: Setup Pages + id: pages + uses: actions/configure-pages@v5 + - name: Build with sphinx + run: cd docs && make html + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./docs/build/html + + # Deployment job + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: docs + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index fea5d8b..04d09f0 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -17,9 +17,7 @@ permissions: jobs: deploy: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Set up Python diff --git a/.github/workflows/test-and-lint.yml b/.github/workflows/test-and-lint.yml new file mode 100644 index 0000000..dd37eee --- /dev/null +++ b/.github/workflows/test-and-lint.yml @@ -0,0 +1,42 @@ + +name: Test & Linting + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + name: Run Tests + container: + image: sudilav1/martepy:latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Run pytest + run: | + pytest --cov=martepy --cov-report=term --cov-report=html:cov_html --cov-fail-under=90 + - name: Upload Coverage Report + uses: actions/upload-artifact@v2 + with: + name: coverage-report + path: cov_html/ + retention-days: 30 + + linting: + runs-on: ubuntu-latest + name: Code Linting + container: + image: sudilav1/martepy:latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run pylint + run: pylint martepy + diff --git a/.gitignore b/.gitignore index db61eca..b137ae0 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ codeclimate.json log.txt tests/marte2/new_headers/* **/*.xmt +dist/* diff --git a/README.md b/README.md index 7ce47b5..cf56d64 100644 --- a/README.md +++ b/README.md @@ -18,16 +18,14 @@ When you require support please open an issue, if you would like to make adjustm **Note: You must comply with our guidelines as per the below.** -[Repository Guidelines](./Guidelines.md) +[Repository Guidelines](https://github.com/ukaea/MARTe2-python/blob/main/Guidelines.md) ## Installation This repo has few dependencies and should auto install these when needed. To install the repo simply clone and install with pip: ``` bash -git clone https://git.ccfe.ac.uk/marte21/public/marte2_python.git -cd marte2_python -pip install ./ +pip install martepy ``` ## Examples diff --git a/pyproject.toml b/pyproject.toml index a3ffa1f..231c37b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta" [project] name = "martepy" -version = "0.1.0" -description = "Python modules for testing data processing codes" +version = "1.0.0" +description = """Python modules that wrap MARTe2 classes and objects into python classes for automation and simplification purposes of developing MARTe2 applications. This also provides tools that are useful for working with MARTe2.""" readme = "README.md" authors = [ { name = "Edward Jones", email = "edward.jones1@ukaea.uk" } @@ -23,7 +23,7 @@ dependencies = [ ] [project.urls] -"Homepage" = "https://git.ccfe.ac.uk/POGDeveloper/martepy" +"Homepage" = "https://github.com/ukaea/MARTe2-python" [tool.setuptools.packages.find] include = ["martepy", "martepy.*"]