diff --git a/.github/workflows/issue_to_jira.yml b/.github/workflows/issue_to_jira.yml index 1401104b..057d0782 100644 --- a/.github/workflows/issue_to_jira.yml +++ b/.github/workflows/issue_to_jira.yml @@ -1,5 +1,3 @@ -# This workflow will create a JIRA issue upon creation of a GitHub issue - name: Create JIRA issue on: @@ -7,30 +5,8 @@ on: types: [opened] jobs: - new_jira_issue: - runs-on: ubuntu-latest - - steps: - - name: JIRA Login - uses: atlassian/gajira-login@v3.0.1 - env: - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - - name: Jira Create issue - id: create_jira_issue - uses: atlassian/gajira-create@v3.0.1 - with: - project: GEOPY - issuetype: Story - summary: ${{ github.event.issue.title }} - description: "_from [GitHub issue #${{ github.event.issue.number }}|${{ github.event.issue.html_url }}]_" - # Additional fields in JSON format - #fields: '{"components": [{"name": "my-app"}]}' - - name: Post JIRA link - uses: peter-evans/create-or-update-comment@v3 - with: - # The number of the issue or pull request in which to create a comment. - issue-number: ${{ github.event.issue.number }} - # The comment body. - body: "JIRA issue [${{ steps.create_jira_issue.outputs.issue }}] was created." + call-workflow-create-jira-issue: + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-jira-issue_to_jira.yml@main + secrets: inherit + with: + project-key: 'GEOPY' diff --git a/.github/workflows/pr_add_jira_summary.yml b/.github/workflows/pr_add_jira_summary.yml index f0c8a8dd..794bf3f0 100644 --- a/.github/workflows/pr_add_jira_summary.yml +++ b/.github/workflows/pr_add_jira_summary.yml @@ -1,6 +1,3 @@ -# This workflow will comment the PR with the JIRA issue summary -# if a JIRA issue number is detected in the branch name or title - name: Add JIRA issue summary on: @@ -8,57 +5,6 @@ on: types: [opened] jobs: - add_jira_summary: - runs-on: ubuntu-latest - - steps: - - name: Find JIRA issue key - id: find_jira_key - env: - HEAD_REF: ${{ github.head_ref}} - PR_TITLE: ${{ github.event.pull_request.title }} - run: > - echo $HEAD_REF $PR_TITLE - | echo "issue_key=$( - grep -osi "\b\(GA\|GEOPY\|DEVOPS\)[ #-]*[0-9]\+" - | head -n1 - | sed -E "s/([A-Z]+)[-# ]*([0-9]+)/\1-\2/i" - | tr [:lower:] [:upper:] - )" - >> $GITHUB_OUTPUT - - name: Get JIRA summary - id: get_jira_summary - if: ${{ steps.find_jira_key.outputs.issue_key }} - env: - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_BASIC_AUTH: ${{ secrets.JIRA_BASIC_AUTH }} - run: > - curl -sS -X GET - -H "Authorization: Basic $JIRA_BASIC_AUTH" - -H "Content-Type: application/json" - "$JIRA_BASE_URL/rest/api/2/issue/${{ steps.find_jira_key.outputs.issue_key }}" - | echo "summary=$(jq -r '.fields.summary // empty')" >> $GITHUB_OUTPUT - - name: Extract PR title - id: get_pr_title - env: - PR_TITLE: ${{ github.event.pull_request.title }} - run: | - echo "text=$(echo $PR_TITLE | sed -E "s/^\s*[?[A-Z]+[-# ]*[0-9]+]?[-: ]*(.*)/\1/i")" >> $GITHUB_OUTPUT - - name: Add comment - if: ${{ steps.find_jira_key.outputs.issue_key }} - env: - ISSUE_SUMMARY: ${{ steps.get_jira_summary.outputs.summary }} - TITLE_TEXT: ${{ steps.get_pr_title.outputs.text }} - PR_BODY: ${{ github.event.pull_request.body }} - run: > - jq - --arg ISSUE_ID "${{ steps.find_jira_key.outputs.issue_key }}" - --arg ISSUE_SUMMARY "$(cat <<< $ISSUE_SUMMARY)" - --arg TITLE_TEXT "$(cat <<< ${TITLE_TEXT:-$ISSUE_SUMMARY})" - --arg PR_BODY "$(cat <<< $PR_BODY)" - -c '{"title": ($ISSUE_ID + ": " + $TITLE_TEXT), "body": ("**" + $ISSUE_ID + " - " + $ISSUE_SUMMARY + "**\n" + $PR_BODY)}' <<< {} - | curl -sS -X POST -d @- - -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" - -H "Content-Type: application/json" - "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}" - > /dev/null + call-workflow-add-jira-issue-summary: + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-jira-pr_add_jira_summary.yml@main + secrets: inherit diff --git a/.github/workflows/pytest-unix-os.yml b/.github/workflows/pytest-unix-os.yml deleted file mode 100644 index 2798e6ea..00000000 --- a/.github/workflows/pytest-unix-os.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: pytest on Unix OS - -on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - branches: - - develop - - main - - release/** - - feature/** - - hotfix/** - push: - branches: - - develop - - main - - release/** - - feature/** - - hotfix/** - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - pytest: - name: pytest (Unix) - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false - strategy: - fail-fast: false - matrix: - python_ver: ['3.10'] - os: [ubuntu-latest] - runs-on: ${{ matrix.os }} - defaults: - run: - shell: bash -l {0} - env: - PYTHONUTF8: 1 - CONDA_CHANNEL_PRIORITY: strict - PIP_NO_DEPS: 1 # all dependencies are installed from conda - CONDA_LOCK_ENV_FILE: environments/py-${{ matrix.python_ver }}-${{ startsWith(matrix.os, 'macos') && 'osx' || 'linux' }}-64-dev.conda.lock.yml - steps: - - uses: actions/checkout@v4 - with: - lfs: true - - name: Setup conda env - uses: mamba-org/setup-micromamba@v1 - with: - environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} - environment-name: test_env - cache-downloads: true - - name: pytest - run: pytest --cov --cov-report=xml diff --git a/.github/workflows/pytest-windows.yml b/.github/workflows/pytest-windows.yml deleted file mode 100644 index 5fd797e6..00000000 --- a/.github/workflows/pytest-windows.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: pytest on Windows - -on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - branches: - - develop - - main - - release/** - - feature/** - - hotfix/** - push: - branches: - - develop - - main - - release/** - - feature/** - - hotfix/** - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -jobs: - pytest: - name: pytest (Windows) - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false - strategy: - fail-fast: false - matrix: - python_ver: ['3.10'] - defaults: - run: - shell: powershell - runs-on: windows-latest - env: - PYTHONUTF8: 1 - CONDA_CHANNEL_PRIORITY: strict - PIP_NO_DEPS: 1 # all dependencies are installed from conda - CONDA_LOCK_ENV_FILE: environments/py-${{ matrix.python_ver }}-win-64-dev.conda.lock.yml - steps: - - uses: actions/checkout@v4 - with: - lfs: true - - name: Setup conda env - uses: mamba-org/setup-micromamba@v1 - with: - environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} - environment-name: test_env - init-shell: powershell - cache-downloads: true - - name: pytest - run: pytest --cov --cov-report=xml - - name: Codecov - if: ${{ success() && matrix.python_ver == '3.10' }} - uses: codecov/codecov-action@v4 - with: - name: GitHub - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/python_analysis.yml b/.github/workflows/python_analysis.yml new file mode 100644 index 00000000..4f9d4ed7 --- /dev/null +++ b/.github/workflows/python_analysis.yml @@ -0,0 +1,44 @@ +name: Python analysis + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + branches: + - develop + - main + - release/** + - feature/** + - hotfix/** + push: + branches: + - develop + - main + - release/** + - feature/** + - hotfix/** + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + call-workflow-static-analysis: + name: Static analysis + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-static_analysis.yml@main + with: + package-manager: 'conda' + app-name: 'simpeg_drivers' + python-version: '3.10' + call-workflow-pytest: + name: Pytest + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-pytest.yml@main + with: + package-manager: 'conda' + python-versions: '["3.10", "3.11"]' + os: '["ubuntu-latest", "windows-latest"]' + cache-number: 1 + codecov-reference-python-version: '3.10' + codecov-reference-os: '["windows-latest"]' + timeout-minutes: 40 + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/python_deploy_dev.yml b/.github/workflows/python_deploy_dev.yml new file mode 100644 index 00000000..e27f17e7 --- /dev/null +++ b/.github/workflows/python_deploy_dev.yml @@ -0,0 +1,35 @@ +name: Deploy python package in development + +on: + push: + tags: + - 'v*' # Push events to every version tag (eg. v1.0.0) + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true + +jobs: + call-workflow-conda-publish: + name: Publish development conda package on JFrog Artifactory + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-publish_conda_package.yml@main + with: + package-name: 'simpeg-drivers' + python-version: '3.10' + virtual-repo-names: '["public-conda-dev"]' + secrets: + JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} + JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} + call-workflow-pypi-publish: + name: Publish development pypi package (JFrog Artifactory, TestPyPI) + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-publish_pypi_package.yml@main + with: + package-manager: 'poetry' + package-name: 'simpeg-drivers' + version-tag: ${{ github.ref_name }} + python-version: '3.10' + virtual-repo-names: '["public-pypi-dev", "test-pypi"]' + secrets: + JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} + JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} + PYPI_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }} diff --git a/.github/workflows/python_deploy_prod.yml b/.github/workflows/python_deploy_prod.yml new file mode 100644 index 00000000..64a5cda1 --- /dev/null +++ b/.github/workflows/python_deploy_prod.yml @@ -0,0 +1,46 @@ +name: Deploy python package in production + +on: + release: + types: [published] + workflow_dispatch: + inputs: + release-tag: + description: 'Tag for the existing (draft) release to publish assets from' + required: true + publish-conda: + description: 'Publish Conda package' + required: false + default: true + publish-pypi: + description: 'Publish PyPI package' + required: false + default: true + +concurrency: + group: ${{ github.workflow }}-${{ github.event.release.tag_name || github.event.inputs.release-tag || github.run_id }} + cancel-in-progress: true + +jobs: + call-workflow-conda-release: + name: Publish production Conda package on JFrog Artifactory + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-release_conda_assets.yml@main + if: ${{ github.event_name == 'release' || github.event.inputs.publish-conda == 'true' }} + with: + virtual-repo-names: '["public-conda-prod"]' + release-tag: ${{ github.event.release.tag_name || github.event.inputs.release-tag }} + secrets: + JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} + JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} + call-workflow-pypi-release: + name: Publish production PyPI package (JFrog Artifactory, PyPI) + if: ${{ github.event_name == 'release' || github.event.inputs.publish-pypi == 'true' }} + uses: MiraGeoscience/CI-tools/.github/workflows/reusable-python-release_pypi_assets.yml@main + with: + package-name: 'simpeg-drivers' + virtual-repo-names: '["public-pypi-prod", "pypi"]' + release-tag: ${{ github.event.release.tag_name || github.event.inputs.release-tag }} + secrets: + JFROG_ARTIFACTORY_URL: ${{ secrets.JFROG_ARTIFACTORY_URL }} + JFROG_ARTIFACTORY_TOKEN: ${{ secrets.JFROG_ARTIFACTORY_TOKEN }} + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml deleted file mode 100644 index be479801..00000000 --- a/.github/workflows/static-analysis.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: static analysis - -on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - branches: - - develop - - main - - release/** - - feature/** - - hotfix/** - push: - branches: - - develop - - main - - release/** - - feature/** - - hotfix/** - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} - cancel-in-progress: true - -env: - source_dir: simpeg_drivers - -jobs: - pylint: - name: pylint - if: github.event_name != 'pull_request' || github.event.pull_request.draft == false - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - env: - PYTHONUTF8: 1 - CONDA_CHANNEL_PRIORITY: strict - PIP_NO_DEPS: 1 # all dependencies are installed from conda - CONDA_LOCK_ENV_FILE: environments/py-3.10-linux-64-dev.conda.lock.yml - steps: - - uses: actions/checkout@v4 - - name: Setup conda env - uses: mamba-org/setup-micromamba@v1 - with: - environment-file: ${{ env.CONDA_LOCK_ENV_FILE }} - environment-name: linter_env - cache-downloads: true - - name: capture modified files - if: github.event_name == 'pull_request' - run: >- - git fetch --deepen=500 origin ${{github.base_ref}} - && echo "FILES_PARAM=$( - git diff --diff-filter=AM --name-only refs/remotes/origin/${{github.base_ref}}... -- | grep -E "^(${source_dir}|tests)/.*\.py$" | xargs - )" >> $GITHUB_ENV - - name: Run pylint on modified files - if: github.event_name == 'pull_request' && env.FILES_PARAM - run: pylint $FILES_PARAM - - name: Run pylint on all files - if: github.event_name == 'push' - run: pylint $source_dir tests diff --git a/.idea/copyright/MiraGeoscience.xml b/.idea/copyright/MiraGeoscience.xml index 6c1fafb5..4ecba321 100644 --- a/.idea/copyright/MiraGeoscience.xml +++ b/.idea/copyright/MiraGeoscience.xml @@ -1,6 +1,8 @@ - - + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml index 7c8bef69..e88ed244 100644 --- a/.idea/copyright/profiles_settings.xml +++ b/.idea/copyright/profiles_settings.xml @@ -8,12 +8,18 @@