Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing github actions #510

Merged
merged 5 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions .github/workflows/docker.yml

This file was deleted.

8 changes: 7 additions & 1 deletion .github/workflows/package-filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ on:
required: true
default: 0
type: number
ignore-missing-dev:
description: "If true, the action will ignore packages that do not have a dev version. Otherwise, the action will fail if any package does not have a dev version."
required: true
default: false
type: boolean
outputs:
matrix:
description: "The directories containing the updated packages"
Expand Down Expand Up @@ -81,7 +86,8 @@ jobs:
# Check that the version is a dev version
if [[ "$(cat ${pkg_dir}/VERSION)" != *"dev"* ]]
then
echo "::error::${pkg_dir} does not have a dev version" && exit 1
msg="${pkg_dir} does not have a dev version"
${{ inputs.ignore-missing-dev }} && echo "::warning::${msg}" || $(echo "::error::${msg}" && exit 1)
fi

PACKAGE_DIRS="$PACKAGE_DIRS ${pkg_dir}"
Expand Down
94 changes: 66 additions & 28 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,32 @@ on:
required: true
default: 1
type: number
ignore-missing-dev:
description: "If true, the action will ignore packages that do not have a dev version. Otherwise, the action will fail if any package does not have a dev version."
required: true
default: true
type: boolean
repo_name:
description: 'Name of the base repository. The user can ignore this input if the action is triggered from the base repository.'
required: true
type: string
default: 'image-tools'
workflow_call:
inputs:
repo_name:
description: 'Name of the base repository'
required: true
type: string
num-commits:
description: "The of commits to check for updated packages. If 0, the action will check all commits on the master branch. For any larger value, the action will check the last n commits for any updated packages."
required: true
default: 1
type: number
ignore-missing-dev:
description: "If true, the action will ignore packages that do not have a dev version. Otherwise, the action will fail if any package does not have a dev version."
required: true
default: true
type: boolean
repo_name:
description: 'Name of the base repository'
required: true
type: string
secrets:
DOCKER_USERNAME:
description: 'Docker Hub username'
Expand All @@ -41,19 +51,20 @@ permissions:

jobs:
package-filter:
name: Filter for updated package
name: Filter for updated packages
if: github.repository == 'polusai/${{ github.event.inputs.repo_name }}'
uses: ./.github/workflows/package-filter.yml
with:
num-commits: ${{ fromJson(github.event.inputs.num-commits) }}
ignore-missing-dev: ${{ fromJson(github.event.inputs.ignore-missing-dev) }}

package-release:
name: Release "${{ matrix.package_name }}"
name: Release | ${{ matrix.package_name }}
if: github.repository == 'polusai/${{ github.event.inputs.repo_name }}'
needs: package-filter
strategy:
fail-fast: false
matrix: ${{fromJson(needs.package-filter.outputs.matrix)}}
matrix: ${{ fromJson(needs.package-filter.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -62,51 +73,78 @@ jobs:
fetch-depth: 0
ref: ${{ github.event.inputs.branch }}
persist-credentials: false
- name: Generate a token
- name: Token | Generate
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Use the token
- name: Token | Use the token
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}
run: |
gh api octocat
- name: Set up Python
- name: Python | Setup
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install bump2version
- name: Python | Install bump2version
run: |
python -m pip install --upgrade pip
pip install bump2version
- name: Bump Version
- name: Python | Bump Version Release
id: bump_version
run: |
cd "${{ matrix.package_dir }}"
bump2version release --no-commit
- name: Commit all changed files
pkg_dir=${{ matrix.package_dir }}
cd "${pkg_dir}"
# check if the package has a dev version
if [[ "$(cat VERSION)" != *dev* ]]
then
msg="${pkg_dir} does not have a dev version"
${{ github.event.inputs.ignore-missing-dev }} && echo "::warning::${msg}" || $(echo "::error::${msg}" && exit 1)
else
bump2version release --no-commit
fi
echo "released=$(git status --porcelain)" >> $GITHUB_output
- name: Git | Commit
if: steps.bump_version.outputs.released == 'true'
env:
CI_COMMIT_AUTHOR: polusai-auth-helper[bot]
CI_COMMIT_EMAIL: ${{ secrets.APP_ID }}+polusai-auth-helper[bot]@users.noreply.github.com
run: |
git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config --global user.email "${{ env.CI_COMMIT_EMAIL }}"
git commit -a -m "build: Bumped release version for ${{ matrix.package_name }}"
- name: Push changes
- name: Git | Push
if: steps.bump_version.outputs.released == 'true'
uses: ad-m/github-push-action@master
with:
force: true
github_token: ${{ steps.generate_token.outputs.token }}

docker:
name: Build Docker images
if: github.repository == 'polusai/${{ github.event.inputs.repo_name }}'
needs: [package-filter, package-release]
uses: ./.github/workflows/docker.yml
with:
matrix: ${{ needs.package-filter.outputs.matrix }}
push: true
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
- name: Docker | Tag
id: docker_tag
run: |
package_dir="${{ matrix.package_dir }}"
cp .gitignore ${package_dir}/.dockerignore
version=$(cat ${package_dir}/VERSION)
tag=polusai/${{ matrix.package_name }}:${version}
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Docker | Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Docker | Login DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Docker | Check if Image exists
run: |
tag=${{ steps.docker_tag.outputs.tag }}
docker pull ${tag} > /dev/null \
&& $(echo "::error::${tag} already exists on DockerHub" && exit 1) \
|| echo "success"
- name: Docekr | Push Image
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:${{ matrix.package_dir }}"
push: true
tags: ${{ steps.docker_tag.outputs.tag }}
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name: Package tests

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}

on:
pull_request:
branches:
Expand All @@ -16,13 +12,6 @@ on:
- master
- dev
workflow_call:
secrets:
DOCKER_USERNAME:
description: 'Docker Hub username'
required: true
DOCKER_TOKEN:
description: 'Docker Hub password'
required: true

permissions:
contents: read
Expand All @@ -33,13 +22,14 @@ jobs:
uses: ./.github/workflows/package-filter.yml
with:
num-commits: 0
ignore-missing-dev: false

tests:
name: Test "${{ matrix.package_name }}"
name: Test | ${{ matrix.package_name }}
needs: package-filter
strategy:
fail-fast: false
matrix: ${{fromJson(needs.package-filter.outputs.matrix)}}
matrix: ${{ fromJson(needs.package-filter.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down Expand Up @@ -69,14 +59,26 @@ jobs:
poetry install
poetry run pytest -v
docker:
name: Build Docker images
needs: [package-filter, tests]
uses: ./.github/workflows/docker.yml
with:
matrix: ${{ needs.package-filter.outputs.matrix }}
push: false
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
- name: Docker | Tag
id: docker_tag
run: |
package_dir="${{ matrix.package_dir }}"
version=$(cat ${package_dir}/VERSION)
tag=polusai/${{ matrix.package_name }}:${version}
echo "tag will be ${tag}"
echo "tag=${tag}" >> $GITHUB_OUTPUT
- name: Docker | Setup Buildx
uses: docker/setup-buildx-action@v3
- name: Docker | Check if Image exists
run: |
tag=${{ steps.docker_tag.outputs.tag }}
docker pull ${tag} > /dev/null \
&& $(echo "::error::${tag} already exists on DockerHub" && exit 1) \
|| echo "success"
- name: Docker | Build Image
run: |
cp .gitignore ${{ matrix.package_dir }}/.dockerignore
cd "${{ matrix.package_dir }}"
tag=${{ steps.docker_tag.outputs.tag }}
docker build . -t ${tag}
# docker buildx build --platform linux/amd64,linux/arm64 -t ${tag} --push .
41 changes: 0 additions & 41 deletions .github/workflows/test-github-app.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[bumpversion]
current_version = 2.1.0
commit = False
current_version = 2.1.1-dev0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<dev>\d+))?
serialize =
Expand Down
2 changes: 1 addition & 1 deletion regression/basic-flatfield-estimation-plugin/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# BaSiC Flatfield Correction (v2.1.0)
# BaSiC Flatfield Correction (v2.1.1-dev0)

This WIPP plugin will take a collection of images and use the BaSiC flatfield
correction algorithm to generate a flatfield image, a darkfield image, and a
Expand Down
2 changes: 1 addition & 1 deletion regression/basic-flatfield-estimation-plugin/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.1.1-dev0
4 changes: 2 additions & 2 deletions regression/basic-flatfield-estimation-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "BaSiC Flatfield Estimation",
"version": "2.1.0",
"version": "2.1.1-dev0",
"title": "Flatfield Estimation using BaSiC algorithm.",
"description": "Generates images used for flatfield correction using the BaSiC algorithm.",
"author": "Nick Schaub (nick.schaub@nih.gov), Najib Ishaq (najib.ishaq@nih.gov)",
"institution": "National Center for the Advancing Translational Sciences, National Institutes of Health",
"repository": "https://github.com/polusai/polus-plugins",
"website": "https://ncats.nih.gov/preclinical/core/informatics",
"citation": "Peng et al. \"A BaSiC tool for background and shading correction of optical microscopy images\" Nature Communications (2017)",
"containerId": "polusai/basic-flatfield-estimation-plugin:2.1.0",
"containerId": "polusai/basic-flatfield-estimation-plugin:2.1.1-dev0",
"baseCommand": [
"python3",
"-m",
Expand Down
Loading