From 622092d92f0f1366e5e6bbf4395b0c6fab6b9288 Mon Sep 17 00:00:00 2001 From: "C. Allwardt" <3979063+craig8@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:54:39 -0700 Subject: [PATCH] Add templates and workflows --- .github/ISSUE_TEMPLATE/bug_report.md | 34 ++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++ .github/workflows/auto-assign-project.yml | 22 ++++ .github/workflows/code-analysis.yml | 70 ++++++++++++ .github/workflows/deploy-pre-release.yml | 125 ++++++++++++++++++++++ .github/workflows/make-release.yml | 65 +++++++++++ .github/workflows/run-tests.yml | 69 ++++++++++++ 7 files changed, 405 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/workflows/auto-assign-project.yml create mode 100644 .github/workflows/code-analysis.yml create mode 100644 .github/workflows/deploy-pre-release.yml create mode 100644 .github/workflows/make-release.yml create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..0661707 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: unconfirmed +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: + +1. Go to '...' +2. Run command '...' +3. Scroll down to '...' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**System (please complete the following information):** + +- `volttron-topic-watcher` version: [e.g. 0.2.1] +- Python version: [e.g. 3.8] +- OS: [Windows/Linux] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..4fe86d5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: feature +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/auto-assign-project.yml b/.github/workflows/auto-assign-project.yml new file mode 100644 index 0000000..5823506 --- /dev/null +++ b/.github/workflows/auto-assign-project.yml @@ -0,0 +1,22 @@ +name: Add bugs to bugs project + +on: + issues: + types: + - opened + +jobs: + add-to-project: + name: Add issue to project + runs-on: ubuntu-latest + steps: + - uses: actions/add-to-project@v0.3.0 + with: + # You can target a repository in a different organization + # to the issue + project-url: https://github.com/orgs/eclipse-volttron/projects/3 + # project-url: https://github.com/orgs//projects/ + # github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} + github-token: ${{ secrets.AUTO_PROJECT_PAT }} + # labeled: bug, needs-triage + # label-operator: OR \ No newline at end of file diff --git a/.github/workflows/code-analysis.yml b/.github/workflows/code-analysis.yml new file mode 100644 index 0000000..5df973c --- /dev/null +++ b/.github/workflows/code-analysis.yml @@ -0,0 +1,70 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: CodeQL + +on: + push: + branches: [main, develop, releases] + pull_request: + # The branches below must be a subset of the branches above + branches: [main, develop, releases] + schedule: + - cron: 34 10 * * 4 + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-20.04 + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [python] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://git.io/codeql-language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/deploy-pre-release.yml b/.github/workflows/deploy-pre-release.yml new file mode 100644 index 0000000..9f256a4 --- /dev/null +++ b/.github/workflows/deploy-pre-release.yml @@ -0,0 +1,125 @@ +--- +name: Deploy Pre-Release Artifacts + +on: + push: + branches: + - develop + +defaults: + run: + shell: bash + +env: + LANG: en_US.utf-8 + LC_ALL: en_US.utf-8 + PYTHON_VERSION: '3.10' + +jobs: + + bump_version: + if: github.ref_name != 'main' + runs-on: ubuntu-22.04 + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Checkout code + uses: actions/checkout@v3.5.2 + with: + fetch-depth: 0 + + - name: Set up Python ${{ env.PYTHON_VERSION }} + id: setup-python + uses: actions/setup-python@v2 + with: + python-version: ${{ env.PYTHON_VERSION }} + + #---------------------------------------------- + # ----- install & configure poetry ----- + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1.3.3 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + #---------------------------------------------- + # load cached venv if cache exists + #---------------------------------------------- + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v2.1.7 + with: + path: .venv + key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} + + #---------------------------------------------- + # install dependencies if cache does not exist + #---------------------------------------------- + - name: Install dependencies + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' + run: poetry install --no-interaction --no-root + + #---------------------------------------------- + # install your root project, if required + #---------------------------------------------- + - name: Install library + run: | + poetry install --no-interaction + + - name: Bump Version + run: | + # current_tag is the last tagged release in the repository. From there + # we need to remove the v from the beginning of the tag. + echo "Bump rule is prerelease" + if ! $(git tag -l "v*" = ''); then + # uses -V which is version sort to keep it monotonically increasing. + current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p) + echo "current git tag is ${current_tag}" + current_tag=${current_tag#?} + # current_tag is now the version we want to set our poetry version so + # that we can bump the version + poetry version ${current_tag} + poetry version prerelease --no-interaction + + else + # very first release. start with inputs.first-release-version + echo "First release. Setting tag as v0.0.1rc0" + current_tag=v0.0.1rc0 + poetry version ${current_tag} + fi + + NEW_TAG=v$(poetry version --short) + + # Finally because we want to be able to use the variable in later + # steps we set a NEW_TAG environmental variable + echo "NEW_TAG=$(echo ${NEW_TAG})" >> $GITHUB_ENV + + #--------------------------------------------------------------- + # create build artifacts to be included as part of release + #--------------------------------------------------------------- + - name: Create build artifacts + run: | + poetry build -vvv + + - uses: ncipollo/release-action@v1.12.0 + with: + artifacts: "dist/*.gz,dist/*.whl" + artifactErrorsFailBuild: true + generateReleaseNotes: true + commit: ${{ github.ref }} + prerelease: true + tag: ${{ env.NEW_TAG }} + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish pre-release to pypi + if: github.repository_owner == 'eclipse-volttron' + run: | + poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} + poetry publish diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml new file mode 100644 index 0000000..83a7a8b --- /dev/null +++ b/.github/workflows/make-release.yml @@ -0,0 +1,65 @@ +name: Make full release + +on: + workflow_dispatch: + inputs: + merge-strategy: + description: 'Merge strategy and strategy options. Used only in case of merge conflicts' + required: false + default: '' + type: string + release-version: + description: 'Version number to use. If provided bump-rule will be ignored' + required: false + default: '' + type: string + bump-rule: + description: 'Bump rule for computing next release version number.' + required: false + default: 'prerelease' + type: choice + options: + - patch + - minor + - major + - prepatch + - preminor + - premajor + - prerelease + run-tests-wait: + description: 'Wait time to run test after merge to main' + required: false + default: 600 + type: number + publish-to-test-pypi: + description: 'Set to true if you want to publish to https://test.pypi.org/legacy/ instead of pypi.org' + required: false + default: false + type: boolean + + +defaults: + run: + shell: bash + +env: + LANG: en_US.utf-8 + LC_ALL: en_US.utf-8 + PYTHON_VERSION: '3.10' + +jobs: + call-deploy-release: + permissions: + contents: write # To push a branch + pull-requests: write # To create a PR from that branch + + uses: eclipse-volttron/github-tooling/.github/workflows/deploy-release.yml@main + with: + merge-strategy: ${{ inputs.merge-strategy }} + release-version: ${{ inputs.release-version }} + bump-rule: ${{ inputs.bump-rule }} + run-tests-wait: 600 + publish-to-test-pypi: false + secrets: + git-token: ${{ secrets.AUTO_PROJECT_PAT }} + pypi-token: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..8cdc647 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,69 @@ +name: Run Pytests + +on: + push: + paths: + - '**.py' + - 'poetry.yml' + pull_request: + types: + - opened + - synchronize + - reopened + paths: + - '**.py' + workflow_dispatch: + +defaults: + run: + shell: bash + +env: + LANG: en_US.utf-8 + LC_ALL: en_US.utf-8 + PYTHON_VERSION: '3.10' + +jobs: + + run-tests: + strategy: + matrix: + os: ["ubuntu-22.04"] + python: ["3.10", "3.11"] + + runs-on: ${{ matrix.os }} + + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + + #---------------------------------------------- + # check-out repo and set-up python + #---------------------------------------------- + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python }} + id: setup-python + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + #---------------------------------------------- + # ----- install & configure poetry ----- + #---------------------------------------------- + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + virtualenvs-create: true + virtualenvs-in-project: true + installer-parallel: true + + #---------------------------------------------- + # install your root project, and run tests. + #---------------------------------------------- + - name: Install library and run tests + run: | + poetry install --no-interaction + poetry run pytest