Skip to content

Commit

Permalink
Merge pull request #2 from equinor/pipelines
Browse files Browse the repository at this point in the history
Pipelines
adamchengtkc authored Nov 10, 2023
2 parents 6dc397d + df54e8b commit d330d46
Showing 40 changed files with 4,373 additions and 880 deletions.
14 changes: 8 additions & 6 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM mcr.microsoft.com/devcontainers/base:bullseye
FROM dolfinx/dolfinx:v0.7.0
# FROM mcr.microsoft.com/devcontainers/base:jammy

ARG DEBIAN_FRONTEND=noninteractive
ARG USER=vscode
# RUN useradd -ms /bin/bash vscode
# ARG USER=vscode

RUN DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
@@ -28,9 +28,11 @@ RUN DEBIAN_FRONTEND=noninteractive \
# Python and poetry installation
USER $USER
ARG HOME="/home/$USER"
ARG PYTHON_VERSION=3.11
# ARG PYTHON_VERSION=3.10

# Don't change. Dolfinx in the base image is only compiled with 3.10
ARG PYTHON_VERSION=3.10

# Use poetry pyenv
ENV PYENV_ROOT="${HOME}/.pyenv"
ENV PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${HOME}/.local/bin:$PATH"

@@ -42,4 +44,4 @@ RUN echo "done 0" \
&& pyenv global ${PYTHON_VERSION} \
&& echo "done 3" \
&& curl -sSL https://install.python-poetry.org | python3 - \
&& poetry config virtualenvs.in-project true
&& poetry config virtualenvs.in-project true
17 changes: 11 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -11,19 +11,24 @@
// "forwardPorts": [],

// 👇 Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "poetry install --with dev --no-interaction",
"postCreateCommand": "bash .devcontainer/postCreate.sh",

// 👇 Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions":["ms-python.python", "njpwerner.autodocstring"]
"extensions":[
"ms-python.python",
"njpwerner.autodocstring",
"ms-python.autopep8",
"ms-toolsai.jupyter",
"ms-python.vscode-pylance",
"ms-azuretools.vscode-docker"
]
}
},
"features": {
"ghcr.io/devcontainers/features/git-lfs:1": {
"autoPull": true,
"version": "latest"
}
"ghcr.io/devcontainers/features/git-lfs:1": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
}

// 👇 Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
2 changes: 2 additions & 0 deletions .devcontainer/postCreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
poetry install --with dev --no-interaction
poetry run pip install petsc4py==3.20.0 mpi4py==3.1.5 https://github.com/FEniCS/ufl/archive/refs/tags/2023.2.0.zip https://github.com/FEniCS/ffcx/archive/v0.7.0.zip https://github.com/FEniCS/basix/archive/v0.7.0.zip
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*.gri filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.gri *.png filter=lfs diff=lfs merge=lfs -text
1 change: 1 addition & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ name: docs

on:
workflow_dispatch:
workflow_call:
push:
branches: [ main ]

64 changes: 64 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: build

on:
workflow_dispatch:

jobs:
test3d:
uses: equinor/warmth/.github/workflows/python-test-3d.yml@main
with:
event_type: ${{ github.event_name}}
action_type: ${{ github.event.action}}
test1d:
uses: equinor/warmth/.github/workflows/python-test.yml@main
with:
event_type: ${{ github.event_name}}
action_type: ${{ github.event.action}}
snyk:
uses: equinor/warmth/.github/workflows/snyk.yml@main
docs:
uses: equinor/warmth/.github/workflows/docs.yml@main

deploy:
needs: [test3d, test1d, snyk, docs]
environment: deploy
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: 'master'
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'

- name: Azure key vault login
uses: Azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Fetch secrets
uses: azure/CLI@v1
with:
azcliversion: 2.42.0
inlineScript: |
echo PYPI_TOKEN=$(az keyvault secret show --vault-name PSSCloudDev --name PYPI-Token --query value -o tsv) >> $GITHUB_ENV
- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
poetry install --with dev --no-interaction
- name: Build and publish
run: |
poetry config pypi-token.pypi ${{ env.PYPI_TOKEN }}
poetry build
poetry publish
40 changes: 40 additions & 0 deletions .github/workflows/python-test-3d.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Tests3D

on:
workflow_call:
inputs:
event_type:
required: true
type: string
action_type:
required: true
type: string
jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Run
uses: tj-actions/docker-run@v2
with:
image: dolfinx/dolfinx:v0.7.0
name: dolfinx
options: -v ${{ github.workspace }}:/warmth
args: |
cd /warmth
pip install .
pip install pytest==7.4.2 pytest-cov==4.1.0
pytest --cov-report=term-missing --cov=warmth/3d tests/3d | tee pytest-coverage.txt
- name: Comment coverage
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
uses: coroo/pytest-coverage-commentator@v1.0.2
with:
pytest-coverage: pytest-coverage.txt
89 changes: 57 additions & 32 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -2,47 +2,72 @@
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Tests

on:
workflow_call:
inputs:
event_type:
required: true
type: string
action_type:
required: true
type: string
workflow_dispatch:
push:
branches: [ main, dev ]
branches: [main, dev]
pull_request:
branches: [ main , dev ]
branches: [main, dev]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10','3.11']
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
poetry install --with dev --no-interaction
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=docs
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=docs
- name: Test with pytest
run: |
poetry run pytest --cov-report=term-missing --cov=warmth tests/ | tee pytest-coverage.txt
- name: Comment coverage
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
uses: coroo/pytest-coverage-commentator@v1.0.2
with:
pytest-coverage: pytest-coverage.txt
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
curl -sSL https://install.python-poetry.org | python3
poetry install --with dev --no-interaction
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
poetry run flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=docs
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
poetry run flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude=docs
- name: Test with pytest
run: |
poetry run pytest --cov-report=term-missing --ignore=tests/3d --cov=warmth tests/ | tee pytest-coverage.txt
- name: Comment coverage
if: ${{ github.event_name == 'pull_request' && github.event.action == 'opened' }}
uses: coroo/pytest-coverage-commentator@v1.0.2
with:
pytest-coverage: pytest-coverage.txt

- name: check_3d_modified
uses: dorny/paths-filter@v2
id: filter3d
with:
filters: |
mesh3d:
- 'warmth/3d/**'
outputs:
filter3d: ${{ steps.filter3d.outputs.mesh3d }}

test3d:
needs: [build]
uses: equinor/warmth/.github/workflows/python-test-3d.yml@main
if: ${{ needs.build.outputs.filter3d }} == 'true'
with:
event_type: ${{ github.event_name}}
action_type: ${{ github.event.action}}
23 changes: 23 additions & 0 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Snyk scan
on:
push:
branches: [main, dev]
pull_request:
branches: [main, dev]
workflow_call:
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Run Snyk to check for vulnerabilities
uses: snyk/actions/python-3.10@master
continue-on-error: false
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
with:
args: --sarif-file-output=snyk.sarif --severity-threshold=high
- name: Upload result to GitHub Code Scanning
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: snyk.sarif
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -62,4 +62,8 @@ exec11/
exec12/
exec13/

docs/_build
docs/_build

*.c
*.o
*.so
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ Standard acronyms to start the commit message with are:
```
API: an (incompatible) API change (will be rare)
PERF: performance or bench-marking
BLD: change related to building xtgeo
BLD: change related to building
BUG: bug fix
FIX: fixes wrt to technical issues, e.g. wrong requirements.txt
DEP: deprecate something, or remove a deprecated object
@@ -98,7 +98,7 @@ Standard acronyms to start the commit message with are:
CLN: code cleanup, maintenance commit (refactoring, typos, PEP, etc.)
REV: revert an earlier commit
TST: addition or modification of tests
REL: related to releasing xtgeo
REL: related to release
```

## Type hints
Loading

0 comments on commit d330d46

Please sign in to comment.