From ee48a48f47185e17c567515b43d3f43257352ae7 Mon Sep 17 00:00:00 2001 From: jtyoung84 <104453205+jtyoung84@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:05:07 -0700 Subject: [PATCH 1/2] ci: updates github actions (#99) * ci: updates github actions --- .github/workflows/publish_main.yml | 94 ++++++++++++ .../{test_and_lint.yml => run_dev_tests.yml} | 4 +- .github/workflows/run_main_tests.yml | 43 ++++++ .github/workflows/tag_and_publish.yml | 138 ------------------ 4 files changed, 139 insertions(+), 140 deletions(-) create mode 100644 .github/workflows/publish_main.yml rename .github/workflows/{test_and_lint.yml => run_dev_tests.yml} (94%) create mode 100644 .github/workflows/run_main_tests.yml delete mode 100644 .github/workflows/tag_and_publish.yml diff --git a/.github/workflows/publish_main.yml b/.github/workflows/publish_main.yml new file mode 100644 index 00000000..a8ab1c98 --- /dev/null +++ b/.github/workflows/publish_main.yml @@ -0,0 +1,94 @@ +name: Tag and publish main +on: + push: + branches: + - main + +jobs: + tag_and_publish: + name: Parse version + runs-on: ubuntu-latest + outputs: + pkg_version: ${{ steps.output_version.outputs.pkg_version }} + steps: + - uses: actions/checkout@v3 + - name: Get version from file + run: | + pkg_name=$(grep -P 'version = \{attr = .*\}' pyproject.toml | grep -oP '\w+.__version__') + init_file="./src/${pkg_name//.__version__}/__init__.py" + pkg_version=$(grep -Po '[0-9]+\.[0-9]+\.[0-9]+' "$init_file") + echo "tag=$pkg_version" >> "$GITHUB_ENV" + - name: Create git tag + run: | + git tag "v${{ env.tag }}" + - name: Push git tag + run: git push origin "v${{ env.tag }}" + - name: Set up Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: '3.10' + - name: Install dependencies + run: | + pip install --upgrade setuptools wheel twine build + python -m build + twine check dist/* + - name: Publish on PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.AIND_PYPI_TOKEN }} + publish_container: + runs-on: ubuntu-latest + env: + GO_VERSION: '1.14.12' + GO_OS: 'linux' + GO_ARCH: 'amd64' + SINGULARITY_VERSION: '3.7.0' + steps: + - uses: actions/checkout@v3 + - name: Get version from file + run: | + pkg_name=$(grep -P 'version = \{attr = .*\}' pyproject.toml | grep -oP '\w+.__version__') + init_file="./src/${pkg_name//.__version__}/__init__.py" + pkg_version=$(grep -Po '[0-9]+\.[0-9]+\.[0-9]+' "$init_file") + echo "tag=$pkg_version" >> "$GITHUB_ENV" + - name: Install dependencies + run: | + sudo apt-get update && sudo apt-get install -y \ + build-essential \ + libssl-dev \ + uuid-dev \ + libgpgme11-dev \ + squashfs-tools \ + libseccomp-dev \ + wget \ + pkg-config \ + procps + - name: Install GO + run: | + wget https://dl.google.com/go/go$GO_VERSION.$GO_OS-$GO_ARCH.tar.gz + sudo tar -C /usr/local -xzvf go$GO_VERSION.$GO_OS-$GO_ARCH.tar.gz + sudo rm go$GO_VERSION.$GO_OS-$GO_ARCH.tar.gz + echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile + - name: Install Singularity + run: | + cd .. + wget https://github.com/hpcng/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-${SINGULARITY_VERSION}.tar.gz + sudo tar -xzf singularity-${SINGULARITY_VERSION}.tar.gz + sudo rm singularity-${SINGULARITY_VERSION}.tar.gz + echo "Finished installing binaries" + export PATH=$PATH:/usr/local/go/bin + cd singularity + sudo ./mconfig --without-suid + sudo make -C ./builddir + sudo make -C ./builddir install + - name: Build sif container + run: | + ls / + ls + mkdir build + sudo singularity build build/container.sif scripts/singularity_build.def + - name: Login and Deploy Container + run: | + echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io + singularity push build/container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${{ env.tag }} + singularity push build/container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:latest diff --git a/.github/workflows/test_and_lint.yml b/.github/workflows/run_dev_tests.yml similarity index 94% rename from .github/workflows/test_and_lint.yml rename to .github/workflows/run_dev_tests.yml index 33ef8a9f..a5a1a187 100644 --- a/.github/workflows/test_and_lint.yml +++ b/.github/workflows/run_dev_tests.yml @@ -1,9 +1,9 @@ -name: Lint and run tests +name: Run checks in dev on: pull_request: branches: - - main + - dev jobs: ci: diff --git a/.github/workflows/run_main_tests.yml b/.github/workflows/run_main_tests.yml new file mode 100644 index 00000000..eb3b2b66 --- /dev/null +++ b/.github/workflows/run_main_tests.yml @@ -0,0 +1,43 @@ +name: Run checks in main and release + +on: + pull_request: + branches: + - '*release*' + - main + +jobs: + ci: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [ '3.10', '3.11' ] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install -e .[dev] + - name: Run linter checks + run: flake8 . && interrogate --verbose . + - name: Run tests and coverage + run: coverage run -m unittest discover && coverage report + verify_version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check version incremented + run: | + pkg_name=$(grep -P 'version = \{attr = .*\}' pyproject.toml | grep -oP '\w+.__version__') + init_file="./src/${pkg_name//.__version__}/__init__.py" + pkg_version=$(grep -Po '[0-9]+\.[0-9]+\.[0-9]+' "$init_file") + latest_tag=$(git ls-remote --tags --refs --sort="v:refname" | tail -n1 | sed 's/.*\///') + echo "Checking pkg_version v$pkg_version and latest_tag $latest_tag" + if [ "$latest_tag" == "v$pkg_version" ] + then + exit 1 + fi + echo "Versions are different" diff --git a/.github/workflows/tag_and_publish.yml b/.github/workflows/tag_and_publish.yml deleted file mode 100644 index 2e67be3b..00000000 --- a/.github/workflows/tag_and_publish.yml +++ /dev/null @@ -1,138 +0,0 @@ -name: Tag and publish -on: - push: - branches: - - main -jobs: - update_badges: - runs-on: ubuntu-latest - continue-on-error: true - steps: - - uses: actions/checkout@v3 - with: - ref: ${{ env.DEFAULT_BRANCH }} - fetch-depth: 0 - token: ${{ secrets.SERVICE_TOKEN }} - - name: Set up Python 3.10 - uses: actions/setup-python@v3 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install -e .[dev] --no-cache-dir - - name: Get Python version and Update README.md - run: | - python_version=$(grep "requires-python" pyproject.toml | grep -o ">=[^\"]*") - python_badge=$(grep -o 'python-[^)]*' README.md) - new_python_badge="python-$python_version-blue?logo=python" - sed -i "s/$python_badge/$new_python_badge/g" README.md - - name: Get interrogate values and Update README.md - run: | - interrogate_val=$(interrogate . | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}') - interrogate_badge=$(grep -o 'interrogate-[^)]*' README.md) - if (( $(echo "$interrogate_val >= 90.00" | bc -l) )); then - new_interrogate_badge="interrogate-$interrogate_val%25-brightgreen" - elif (( $(echo "$interrogate_val < 80.00" | bc -l) )); then - new_interrogate_badge="interrogate-$interrogate_val%25-red" - else - new_interrogate_badge="interrogate-$interrogate_val%25-yellow" - fi - sed -i "s/$interrogate_badge/$new_interrogate_badge/g" README.md - - name: Get Coverage values and Update README.md - run: | - coverage run -m unittest discover - coverage_val=$(coverage report | grep "^TOTAL" | grep -o '[0-9]\+%' | grep -o '[0-9]\+') - coverage_badge=$(grep -o "coverage-[^?]*" README.md) - if (( $(echo "$coverage_val >= 90.00" | bc -l) )); then - new_coverage_badge="coverage-$coverage_val%25-brightgreen" - elif (( $(echo "$coverage_val < 80.00" | bc -l) )); then - new_coverage_badge="coverage-$coverage_val%25-red" - else - new_coverage_badge="coverage-$coverage_val%25-yellow" - fi - sed -i "s/$coverage_badge/$new_coverage_badge/g" README.md - - name: Commit changes - uses: EndBug/add-and-commit@v9 - with: - default_author: github_actions - message: "ci: update badges [skip actions]" - add: '["README.md"]' - tag: - needs: update_badges - uses: AllenNeuralDynamics/aind-github-actions/.github/workflows/tag.yml@main - secrets: - SERVICE_TOKEN: ${{ secrets.SERVICE_TOKEN }} - publish: - needs: tag - if: true - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Pull latest changes - run: git pull origin main - - name: Set up Python 3.10 - uses: actions/setup-python@v2 - with: - python-version: '3.10' - - name: Install dependencies - run: | - pip install --upgrade setuptools wheel twine build - python -m build - twine check dist/* - - name: Publish on PyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - password: ${{ secrets.AIND_PYPI_TOKEN }} - publish_container: - runs-on: ubuntu-latest - env: - GO_VERSION: '1.14.12' - GO_OS: 'linux' - GO_ARCH: 'amd64' - SINGULARITY_VERSION: '3.7.0' - needs: tag - steps: - - uses: actions/checkout@v3 - - name: Pull latest changes - run: git pull origin main - - name: Install dependencies - run: | - sudo apt-get update && sudo apt-get install -y \ - build-essential \ - libssl-dev \ - uuid-dev \ - libgpgme11-dev \ - squashfs-tools \ - libseccomp-dev \ - wget \ - pkg-config \ - procps - - name: Install GO - run: | - wget https://dl.google.com/go/go$GO_VERSION.$GO_OS-$GO_ARCH.tar.gz - sudo tar -C /usr/local -xzvf go$GO_VERSION.$GO_OS-$GO_ARCH.tar.gz - sudo rm go$GO_VERSION.$GO_OS-$GO_ARCH.tar.gz - echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee -a /etc/profile - - name: Install Singularity - run: | - cd .. - wget https://github.com/hpcng/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-${SINGULARITY_VERSION}.tar.gz - sudo tar -xzf singularity-${SINGULARITY_VERSION}.tar.gz - sudo rm singularity-${SINGULARITY_VERSION}.tar.gz - echo "Finished installing binaries" - export PATH=$PATH:/usr/local/go/bin - cd singularity - sudo ./mconfig --without-suid - sudo make -C ./builddir - sudo make -C ./builddir install - - name: Build sif container - run: | - ls / - ls - mkdir build - sudo singularity build build/container.sif scripts/singularity_build.def - - name: Login and Deploy Container - run: | - echo ${{ secrets.GITHUB_TOKEN }} | singularity remote login -u ${{ github.actor }} --password-stdin oras://ghcr.io - singularity push build/container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:${{ needs.tag.outputs.new_version }} - singularity push build/container.sif oras://ghcr.io/${GITHUB_REPOSITORY}:latest From 2aa8b3fe59440c08a2889ba8ca0512099f3410f8 Mon Sep 17 00:00:00 2001 From: jtyoung84 <104453205+jtyoung84@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:07:03 -0700 Subject: [PATCH 2/2] release: v0.14.0 --- src/aind_metadata_mapper/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aind_metadata_mapper/__init__.py b/src/aind_metadata_mapper/__init__.py index 2966b686..77cd89c4 100644 --- a/src/aind_metadata_mapper/__init__.py +++ b/src/aind_metadata_mapper/__init__.py @@ -1,3 +1,3 @@ """Init package""" -__version__ = "0.13.2" +__version__ = "0.14.0"