Skip to content

Commit

Permalink
Merge pull request #4 from digicatapult/feat/set-up-repo
Browse files Browse the repository at this point in the history
Feat/set up repo
  • Loading branch information
Ellenn-A authored May 21, 2024
2 parents ca774dc + c0cf5aa commit 1a89932
Show file tree
Hide file tree
Showing 25 changed files with 3,443 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Github CODEOWNERS file

# Global code-owners for this repository

- @digicatapult/software-engineering
45 changes: 45 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Pull Request

## Checklist

- [ ] Have you read nice-fetch-ai-adapter's Code of Conduct? https://github.com/digicatapult/nice-fetch-ai-adapter/.github/blob/main/CODE_OF_CONDUCT.md
- [ ] I have performed a self-review of my own code.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have made corresponding changes to the documentation.
- [ ] My changes generate no new warnings.
- [ ] I have added tests that prove my fix is effective or that my feature works.
- [ ] New and existing unit tests pass locally with my changes.

## PR Type

Please delete options that are irrelevant.

- [ ] Bug Fix
- [ ] Feature
- [ ] Documentation Update
- [ ] Code style update (formatting, local variables)
- [ ] Breaking Change (fix or feature that would cause existing functionality to change)

## Linked tickets

<!-- If this PR is linked to a JIRA ticket, please provide the ticket URL here. -->

## High level description

<!-- One paragraph explanation of the feature. -->

## Detailed description

<!-- A detailed description of the feature and if possible describe how has been implemented. -->

## Describe alternatives you've considered

<!-- A clear and concise description of the alternative solutions you've considered. Be sure to explain why nice-fetch-ai-adapter's existing customisability isn't suitable for this feature. -->

## Operational impact

<!--- A description of any operational considerations associated with the change. Is there anything in particular we should be looking at when deploying the change to make sure it is working as intended. If something goes wrong will any special actions be needed to revert the change. -->

## Additional context

<!-- Add any other context or screenshots about the feature request here. -->
47 changes: 47 additions & 0 deletions .github/workflows/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Bug report
about: Create a report to help us improve
ticket: Ticket number for this bug (if applicable)
---

<!--
Have you read nice-fetch-ai-adapter's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/digicatapult/nice-fetch-ai-adapter/blob/main/CODE_OF_CONDUCT.md
-->

### Prerequisites

- [ ] Put an X between the brackets on this line if you have done all of the following:
- Checked the FAQs for common solutions: <https://github.com/digicatapult/nice-fetch-ai-adapter/blob/main/CONTRIBUTING.md/#FAQs>
- Checked that your issue isn't already filed: <https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Anice-fetch-ai-adapter>

### Description

<!-- Description of the issue -->

### Steps to Reproduce

1. <!-- First Step -->
2. <!-- Second Step -->
3. <!-- and so on… -->

**Expected behaviour:**

<!-- What you expect to happen -->

**Actual behaviour:**

<!-- What actually happens -->

**Reproduces how often:**

<!-- What percentage of the time does it reproduce? -->

### Versions

<!-- You can get this information from copy and pasting the version on the home page or via package.json. Also, please include the OS and what version of the OS you're running. -->

### Additional Information

<!-- Any additional information, configuration or data that might be necessary to reproduce the issue. -->
34 changes: 34 additions & 0 deletions .github/workflows/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Feature
about: What is this feature adding or changing?
ticket: Ticket number for this feature (if applicable)
---

<!--
Have you read nice-fetch-ai-adapter's Code of Conduct? By filing an Issue, you are expected to comply with it, including treating everyone with respect: https://github.com/digicatapult/nice-fetch-ai-adapter/blob/main/CODE_OF_CONDUCT.md
---
Also note that the Digital Catapult team has finite resources so we have limited opportunity to work on feature requests. If we're interested in a particular feature however, we'll follow up and ask you to submit an RFC to talk about it in more detail.
-->

## High level description

<!-- One paragraph explanation of the feature. -->

## Detailed description

<!-- A detailed description of the feature and if possible describe how has been implemented. -->

## Describe alternatives you've considered

<!-- A clear and concise description of the alternative solutions you've considered. Be sure to explain why nice-fetch-ai-adapter's existing customisability isn't suitable for this feature. -->

## Operational impact

<!--- A description of any operational considerations associated with the change. Is there anything in particular we should be looking at when deploying the change to make sure it is working as intended. If something goes wrong will any special actions be needed to revert the change. -->

## Additional context

<!-- Add any other context or screenshots about the feature request here. -->
160 changes: 160 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Release

on:
push:
branches: ["main"]

jobs:
preconditions:
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.repo_ids.outputs.REPO_NAME }}
org_name: ${{ steps.repo_ids.outputs.ORG_NAME }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check token
run: |
if [ -z "${{ secrets.GITHUB_TOKEN }}"]; then
echo "Must provide a GITHUB_TOKEN secret in order to run release workflow"
exit 1
fi
- name: Get repository identifiers
id: repo_ids
run: |
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
ORG_NAME=$(echo "${{ github.event.repository.owner.name }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_OUTPUT
echo "ORG_NAME=$ORG_NAME" >> $GITHUB_OUTPUT
lint:
name: Run lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
- name: Install Packages
run: poetry install --no-interaction --no-ansi
- name: Lint
run: poetry run flake8
check-version:
name: "Check version"
runs-on: ubuntu-latest
outputs:
is_new_version: ${{ steps.get_version.outputs.IS_NEW_VERSION }}
version: ${{ steps.get_version.outputs.VERSION }}
build_date: ${{ steps.get_version.outputs.BUILD_DATE }}
is_prerelease: ${{ steps.get_version.outputs.IS_PRERELEASE }}

steps:
- uses: actions/checkout@v4
- name: Check version
id: get_version
uses: digicatapult/check-version@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
package_manager: "poetry"
publish:
name: "Publish package"
needs: [preconditions, lint, dependency-check, tests, check-version]
runs-on: ubuntu-latest
# comment the line above to force publish
if: ${{ needs.check-version.outputs.is_new_version == 'true' }}

steps:
- uses: actions/checkout@v4

# Docker build
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: "--debug"
- name: Generate tags
id: generate-tags
env:
VERSION: ${{ needs.check-version.outputs.version }}
IS_NEW_VERSION: ${{ needs.check-version.outputs.is_new_version }}
IS_PRERELEASE: ${{ needs.check-version.outputs.is_prerelease }}
# if it's a new non prerelease version tag with hash, version latest-dev and latest
# if it's a new prerelease version tag with hash, version and latest-dev
# if it's a non new version tag with hash and latest-dev
# add the following in run to force publish: IS_NEW_VERSION="true"; VERSION=0.2.0
run: |
if [ "$IS_NEW_VERSION" == "true" ]; then
echo "GHCR_VERSION_TAG=ghcr.io/${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:$VERSION" >> $GITHUB_OUTPUT
echo "DOCKERHUB_VERSION_TAG=${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:$VERSION" >> $GITHUB_OUTPUT
if [ "$IS_PRERELEASE" == "false" ]; then
echo "GHCR_LATEST_TAG=ghcr.io/${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:latest" >> $GITHUB_OUTPUT
echo "DOCKERHUB_LATEST_TAG=${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:latest" >> $GITHUB_OUTPUT
else
echo "GHCR_LATEST_TAG=" >> $GITHUB_OUTPUT
echo "DOCKERHUB_LATEST_TAG=" >> $GITHUB_OUTPUT
fi;
else
echo "GHCR_VERSION_TAG=" >> $GITHUB_OUTPUT
echo "GHCR_LATEST_TAG=" >> $GITHUB_OUTPUT
echo "DOCKERHUB_VERSION_TAG=" >> $GITHUB_OUTPUT
echo "DOCKERHUB_LATEST_TAG=" >> $GITHUB_OUTPUT
fi;
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub Registry
uses: docker/login-action@v3
with:
username: ${{ secrets.SQNC_DOCKERHUB_USERNAME }}
password: ${{ secrets.SQNC_DOCKERHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/amd64, linux/arm64
push: true
tags: |
ghcr.io/${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:${{ github.sha }}
${{ steps.generate-tags.outputs.GHCR_VERSION_TAG }}
${{ steps.generate-tags.outputs.GHCR_LATEST_TAG }}
${{ needs.preconditions.outputs.org_name }}/${{ needs.preconditions.outputs.repo_name }}:${{ github.sha }}
${{ steps.generate-tags.outputs.DOCKERHUB_VERSION_TAG }}
${{ steps.generate-tags.outputs.DOCKERHUB_LATEST_TAG }}
labels: |
org.opencontainers.image.title=${{ needs.preconditions.outputs.repo_name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ needs.check-version.outputs.version }}
org.opencontainers.image.created
# Build github release
- name: Build release version
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ needs.check-version.outputs.version }}
prerelease: false
title: Release ${{ needs.check-version.outputs.version }}
- name: Build release latest
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: latest
prerelease: false
title: Latest Release ${{ needs.check-version.outputs.version }}
70 changes: 70 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Lint and Test

on:
push:
branches-ignore: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.sha }}
cancel-in-progress: true

jobs:
repo_ids:
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.repo_ids.outputs.REPO_NAME }}
org_name: ${{ steps.repo_ids.outputs.ORG_NAME }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get repository identifiers
id: repo_ids
run: |
REPO_NAME=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
ORG_NAME=$(echo "${{ github.event.repository.owner.name }}" | tr '[:upper:]' '[:lower:]')
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_OUTPUT
echo "ORG_NAME=$ORG_NAME" >> $GITHUB_OUTPUT
lint:
name: Run lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
- name: Install Packages
run: poetry install --no-interaction --no-ansi
- name: Lint
run: poetry run flake8
tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: poetry
- name: Install Packages
run: poetry install --no-interaction --no-ansi
- name: Run tests
run: poetry run pytest -v -s -W ignore::DeprecationWarning
check-version:
name: "Check version"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check version
id: get_version
uses: digicatapult/check-version@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
package_manager: "poetry"
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
*.pyc
*.log
*.swp
*.pem
.idea
*.env
py3env/
__pycache__
htmlcov/
.coverage
.coverage.*
coverage.xml
*.cover
.tag*
node_modules
coverage
.DS_Store
.nyc_output
.env
.helmignore
.vscode
github_token
helm/**/*.tgz
jsHelper.js
.pytest_cache/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.2
Loading

0 comments on commit 1a89932

Please sign in to comment.