diff --git a/.flake8 b/.flake8 index 2ea7395..2d028b2 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,7 @@ [flake8] filename = - *.py + *.py, + *.pys max-line-length = 120 extend-exclude = venv/ diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b67ea63..88c8339 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -9,7 +9,7 @@ updates: directory: "/" schedule: interval: "daily" - time: "00:00" + time: "08:00" target-branch: "nightly" open-pull-requests-limit: 10 @@ -17,7 +17,7 @@ updates: directory: "/" schedule: interval: "daily" - time: "00:00" + time: "08:30" target-branch: "nightly" open-pull-requests-limit: 10 @@ -25,7 +25,15 @@ updates: directory: "/" schedule: interval: "daily" - time: "00:00" + time: "09:00" + target-branch: "nightly" + open-pull-requests-limit: 10 + + - package-ecosystem: "nuget" + directory: "/" + schedule: + interval: "daily" + time: "09:30" target-branch: "nightly" open-pull-requests-limit: 10 @@ -33,6 +41,14 @@ updates: directory: "/" schedule: interval: "daily" - time: "00:00" + time: "10:00" + target-branch: "nightly" + open-pull-requests-limit: 10 + + - package-ecosystem: "gitsubmodule" + directory: "/" + schedule: + interval: "daily" + time: "10:30" target-branch: "nightly" open-pull-requests-limit: 10 diff --git a/.github/pr_release_template.md b/.github/pr_release_template.md index 7c96c6b..b6f6acf 100644 --- a/.github/pr_release_template.md +++ b/.github/pr_release_template.md @@ -17,8 +17,12 @@ This PR was created automatically. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] Dependency update (updates to dependencies) - [ ] Documentation update (changes to documentation) -- [ ] Repository update (changes to repository files) +- [ ] Repository update (changes to repository files, e.g. `.github/...`) + +## Branch Updates +- [x] I want maintainers to keep my branch updated ## Changelog Summary diff --git a/.github/workflows/auto-create-pr.yml b/.github/workflows/auto-create-pr.yml index ef19e40..811747c 100644 --- a/.github/workflows/auto-create-pr.yml +++ b/.github/workflows/auto-create-pr.yml @@ -3,6 +3,9 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# This workflow creates a PR automatically when anything is merged/pushed into the `nightly` branch. The PR is created +# against the `master` (default) branch. + name: Auto create PR on: @@ -12,6 +15,7 @@ on: jobs: create_pr: + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 7ff83e0..4774eb2 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -3,6 +3,8 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# This workflow will, first, automatically approve PRs created by @LizardByte-bot. Then it will automerge relevant PRs. + name: Automerge PR on: @@ -11,15 +13,20 @@ on: - opened - synchronize +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: autoapprove: - if: > + if: >- contains(fromJson('["LizardByte-bot"]'), github.event.pull_request.user.login) && - contains(fromJson('["LizardByte-bot"]'), github.actor) + contains(fromJson('["LizardByte-bot"]'), github.actor) && + startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: Autoapproving - uses: hmarr/auto-approve-action@v2 + uses: hmarr/auto-approve-action@v3 with: github-token: "${{ secrets.GITHUB_TOKEN }}" @@ -36,20 +43,18 @@ jobs: }) automerge: + if: startsWith(github.repository, 'LizardByte/') needs: [autoapprove] runs-on: ubuntu-latest - concurrency: - group: automerge-${{ github.ref }} - cancel-in-progress: true steps: - name: Automerging - uses: pascalgn/automerge-action@v0.15.3 + uses: pascalgn/automerge-action@v0.15.5 env: BASE_BRANCHES: nightly GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} GITHUB_LOGIN: ${{ secrets.GH_BOT_NAME }} - MERGE_LABELS: "" + MERGE_LABELS: "!dependencies" MERGE_METHOD: "squash" MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" MERGE_DELETE_BRANCH: true diff --git a/.github/workflows/autoupdate-labeler.yml b/.github/workflows/autoupdate-labeler.yml new file mode 100644 index 0000000..974c9fa --- /dev/null +++ b/.github/workflows/autoupdate-labeler.yml @@ -0,0 +1,72 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +# Label PRs with `autoupdate` if various conditions are met, otherwise, remove the label. + +name: Label PR autoupdate + +on: + pull_request_target: + types: + - edited + - opened + - reopened + - synchronize + +jobs: + label_pr: + if: >- + startsWith(github.repository, 'LizardByte/') && + contains(github.event.pull_request.body, fromJSON('"] I want maintainers to keep my branch updated"')) + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + steps: + - name: Check if member + id: org_member + run: | + status="true" + gh api \ + -H "Accept: application/vnd.github+json" \ + /orgs/${{ github.repository_owner }}/members/${{ github.actor }} || status="false" + + echo "result=${status}" >> $GITHUB_OUTPUT + + - name: Label autoupdate + if: >- + steps.org_member.outputs.result == 'true' && + contains(github.event.pull_request.labels.*.name, 'autoupdate') == false && + contains(github.event.pull_request.body, + fromJSON('"\n- [x] I want maintainers to keep my branch updated"')) == true + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['autoupdate'] + }) + + - name: Unlabel autoupdate + if: >- + contains(github.event.pull_request.labels.*.name, 'autoupdate') && + ( + (github.event.action == 'synchronize' && steps.org_member.outputs.result == 'false') || + (contains(github.event.pull_request.body, + fromJSON('"\n- [x] I want maintainers to keep my branch updated"')) == false + ) + ) + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} + script: | + github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: ['autoupdate'] + }) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index f32e65c..83f4e16 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -3,11 +3,13 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. -# This workflow is designed to work with: -# - automerge workflows +# This workflow is designed to work with the following workflows: +# - automerge +# - autoupdate-labeler -# It uses GitHub Action that auto-updates pull requests branches, when changes are pushed to their destination branch. +# It uses an action that auto-updates pull requests branches, when changes are pushed to their destination branch. # Auto-updating to the latest destination branch works only in the context of upstream repo and not forks. +# Dependabot PRs are updated by an action that comments `@depdenabot rebase` on dependabot PRs. (disabled) name: autoupdate @@ -17,7 +19,7 @@ on: - 'nightly' jobs: - autoupdate-for-bot: + autoupdate: name: Autoupdate autoapproved PR created in the upstream if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest @@ -25,8 +27,25 @@ jobs: - name: Update uses: docker://chinthakagodawita/autoupdate-action:v1 env: + EXCLUDED_LABELS: "central_dependency,dependencies" GITHUB_TOKEN: '${{ secrets.GH_BOT_TOKEN }}' PR_FILTER: "labelled" PR_LABELS: "autoupdate" - PR_READY_STATE: "ready_for_review" - MERGE_CONFLICT_ACTION: "ignore" + PR_READY_STATE: "all" + MERGE_CONFLICT_ACTION: "fail" + +# Disabled due to: +# - no major version tag, resulting in constant nagging to update this action +# - additionally, the code is sketchy, 16k+ lines of code? +# https://github.com/bbeesley/gha-auto-dependabot-rebase/blob/main/dist/main.cjs +# +# dependabot-rebase: +# name: Dependabot Rebase +# if: >- +# startsWith(github.repository, 'LizardByte/') +# runs-on: ubuntu-latest +# steps: +# - name: rebase +# uses: "bbeesley/gha-auto-dependabot-rebase@v1.3.18" +# env: +# GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index ed36038..3858ae1 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -3,6 +3,21 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# This workflow is intended to work with all our organization Docker projects. A readme named `DOCKER_README.md` +# will be used to update the description on Docker hub. + +# custom comments in dockerfiles: + +# `# platforms: ` +# Comma separated list of platforms, i.e. `# platforms: linux/386,linux/amd64`. Docker platforms can alternatively +# be listed in a file named `.docker_platforms`. +# `# platforms_pr: ` +# Comma separated list of platforms to run for PR events, i.e. `# platforms_pr: linux/amd64`. This will take +# precedence over the `# platforms: ` directive. +# `# artifacts: ` +# `true` to build in two steps, stopping at `artifacts` build stage and extracting the image from there to the +# GitHub runner. + name: CI Docker on: @@ -13,46 +28,60 @@ on: branches: [master, nightly] workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - check_dockerfile: - name: Check Dockerfile + check_dockerfiles: + name: Check Dockerfiles runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - name: Check - id: check + - name: Find dockerfiles + id: find run: | - if [ -f "./Dockerfile" ] - then - FOUND=true - else - FOUND=false - fi + dockerfiles=$(find . -type f -iname "Dockerfile" -o -iname "*.dockerfile") - echo "::set-output name=dockerfile::${FOUND}" + echo "found dockerfiles: ${dockerfiles}" - outputs: - dockerfile: ${{ steps.check.outputs.dockerfile }} + # do not quote to keep this as a single line + echo dockerfiles=${dockerfiles} >> $GITHUB_OUTPUT - lint_dockerfile: - name: Lint Dockerfile - needs: [check_dockerfile] - if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }} - runs-on: ubuntu-latest - steps: - - name: Lint Dockerfile - uses: actions/checkout@v3 + MATRIX_COMBINATIONS="" + for FILE in ${dockerfiles}; do + # extract tag from file name + tag=$(echo $FILE | sed -r -z -e 's/(\.\/)*.*\/(Dockerfile)/None/gm') + if [[ $tag == "None" ]]; then + MATRIX_COMBINATIONS="$MATRIX_COMBINATIONS {\"dockerfile\": \"$FILE\"}," + else + tag=$(echo $FILE | sed -r -z -e 's/(\.\/)*.*\/(.+)(\.dockerfile)/-\2/gm') + MATRIX_COMBINATIONS="$MATRIX_COMBINATIONS {\"dockerfile\": \"$FILE\", \"tag\": \"$tag\"}," + fi + done - - uses: hadolint/hadolint-action@v2.1.0 - with: - dockerfile: ./Dockerfile + # removes the last character (i.e. comma) + MATRIX_COMBINATIONS=${MATRIX_COMBINATIONS::-1} + + # setup matrix for later jobs + matrix=$(( + echo "{ \"include\": [$MATRIX_COMBINATIONS] }" + ) | jq -c .) + + echo $matrix + echo $matrix | jq . + echo "matrix=$matrix" >> $GITHUB_OUTPUT + + outputs: + dockerfiles: ${{ steps.find.outputs.dockerfiles }} + matrix: ${{ steps.find.outputs.matrix }} check_changelog: name: Check Changelog - needs: [check_dockerfile] - if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }} + needs: [check_dockerfiles] + if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} runs-on: ubuntu-latest steps: - name: Checkout @@ -68,15 +97,99 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} outputs: next_version: ${{ steps.verify_changelog.outputs.changelog_parser_version }} + next_version_bare: ${{ steps.verify_changelog.outputs.changelog_parser_version_bare }} + last_version: ${{ steps.verify_changelog.outputs.latest_release_tag_name }} + release_body: ${{ steps.verify_changelog.outputs.changelog_parser_description }} + + setup_release: + name: Setup Release + needs: check_changelog + runs-on: ubuntu-latest + steps: + - name: Set release details + id: release_details + env: + RELEASE_BODY: ${{ needs.check_changelog.outputs.release_body }} + run: | + # determine to create a release or not + if [[ $GITHUB_EVENT_NAME == "push" ]]; then + RELEASE=true + else + RELEASE=false + fi + + # set the release tag + COMMIT=${{ github.sha }} + if [[ $GITHUB_REF == refs/heads/master ]]; then + TAG="${{ needs.check_changelog.outputs.next_version }}" + RELEASE_NAME="${{ needs.check_changelog.outputs.next_version }}" + RELEASE_BODY="$RELEASE_BODY" + PRE_RELEASE="false" + elif [[ $GITHUB_REF == refs/heads/nightly ]]; then + TAG="nightly-dev" + RELEASE_NAME="nightly" + RELEASE_BODY="automated nightly release - $(date -u +'%Y-%m-%dT%H:%M:%SZ') - ${COMMIT}" + PRE_RELEASE="true" + fi + + echo "create_release=${RELEASE}" >> $GITHUB_OUTPUT + echo "release_tag=${TAG}" >> $GITHUB_OUTPUT + echo "release_commit=${COMMIT}" >> $GITHUB_OUTPUT + echo "release_name=${RELEASE_NAME}" >> $GITHUB_OUTPUT + echo "pre_release=${PRE_RELEASE}" >> $GITHUB_OUTPUT + + # this is stupid but works for multiline strings + echo "RELEASE_BODY<> $GITHUB_ENV + echo "$RELEASE_BODY" >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + + outputs: + create_release: ${{ steps.release_details.outputs.create_release }} + release_tag: ${{ steps.release_details.outputs.release_tag }} + release_commit: ${{ steps.release_details.outputs.release_commit }} + release_name: ${{ steps.release_details.outputs.release_name }} + release_body: ${{ env.RELEASE_BODY }} + pre_release: ${{ steps.release_details.outputs.pre_release }} + + lint_dockerfile: + needs: [check_dockerfiles] + if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.check_dockerfiles.outputs.matrix) }} + name: Lint Dockerfile${{ matrix.tag }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Hadolint + id: hadolint + uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: ${{ matrix.dockerfile }} + ignore: DL3008,DL3013,DL3016,DL3018,DL3028,DL3059 + output-file: ./hadolint.log + verbose: true + + - name: Log + if: failure() + run: | + echo "Hadolint outcome: ${{ steps.hadolint.outcome }}" >> $GITHUB_STEP_SUMMARY + cat "./hadolint.log" >> $GITHUB_STEP_SUMMARY docker: - name: Docker - needs: [check_dockerfile, check_changelog] - if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }} + needs: [check_dockerfiles, check_changelog, setup_release] + if: ${{ needs.check_dockerfiles.outputs.dockerfiles }} runs-on: ubuntu-latest permissions: packages: write contents: write + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.check_dockerfiles.outputs.matrix) }} + name: Docker${{ matrix.tag }} steps: - name: Checkout @@ -87,13 +200,12 @@ jobs: - name: Prepare id: prepare env: - NEXT_VERSION: ${{ needs.check_changelog.outputs.next_version }} + NV: ${{ needs.check_changelog.outputs.next_version }} run: | # get branch name BRANCH=${GITHUB_HEAD_REF} - if [ -z "$BRANCH" ] - then + if [ -z "$BRANCH" ]; then echo "This is a PUSH event" BRANCH=${{ github.ref_name }} fi @@ -110,30 +222,65 @@ jobs: BASE_TAG=$(echo $REPOSITORY | tr '[:upper:]' '[:lower:]') COMMIT=${{ github.sha }} - TAGS="${BASE_TAG}:${COMMIT:0:7},ghcr.io/${BASE_TAG}:${COMMIT:0:7}" + TAGS="${BASE_TAG}:${COMMIT:0:7}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${COMMIT:0:7}${{ matrix.tag }}" if [[ $GITHUB_REF == refs/heads/master ]]; then - TAGS="${TAGS},${BASE_TAG}:latest,ghcr.io/${BASE_TAG}:latest" - TAGS="${TAGS},${BASE_TAG}:master,ghcr.io/${BASE_TAG}:master" + TAGS="${TAGS},${BASE_TAG}:latest${{ matrix.tag }},ghcr.io/${BASE_TAG}:latest${{ matrix.tag }}" + TAGS="${TAGS},${BASE_TAG}:master${{ matrix.tag }},ghcr.io/${BASE_TAG}:master${{ matrix.tag }}" elif [[ $GITHUB_REF == refs/heads/nightly ]]; then - TAGS="${TAGS},${BASE_TAG}:nightly,ghcr.io/${BASE_TAG}:nightly" + TAGS="${TAGS},${BASE_TAG}:nightly${{ matrix.tag }},ghcr.io/${BASE_TAG}:nightly${{ matrix.tag }}" else - TAGS="${TAGS},${BASE_TAG}:test,ghcr.io/${BASE_TAG}:test" + TAGS="${TAGS},${BASE_TAG}:test${{ matrix.tag }},ghcr.io/${BASE_TAG}:test${{ matrix.tag }}" fi - if [[ ${NEXT_VERSION} != "" ]]; then - TAGS="${TAGS},${BASE_TAG}:${NEXT_VERSION},ghcr.io/${BASE_TAG}:${NEXT_VERSION}" + if [[ ${NV} != "" ]]; then + TAGS="${TAGS},${BASE_TAG}:${NV}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${NV}${{ matrix.tag }}" fi - # read the platforms from `.docker_platforms` - PLATFORMS=$(<.docker_platforms) + # parse custom directives out of dockerfile + # try to get the platforms from the dockerfile custom directive, i.e. `# platforms: xxx,yyy` + # directives for PR event, i.e. not push event + if [[ ${PUSH} == "false" ]]; then + while read -r line; do + if [[ $line == "# platforms_pr: "* && $PLATFORMS == "" ]]; then + # echo the line and use `sed` to remove the custom directive + PLATFORMS=$(echo -e "$line" | sed 's/# platforms_pr: //') + elif [[ $PLATFORMS != "" ]]; then + # break while loop once all custom "PR" event directives are found + break + fi + done <"${{ matrix.dockerfile }}" + fi + # directives for all events... above directives will not be parsed if they were already found + while read -r line; do + if [[ $line == "# platforms: "* && $PLATFORMS == "" ]]; then + # echo the line and use `sed` to remove the custom directive + PLATFORMS=$(echo -e "$line" | sed 's/# platforms: //') + elif [[ $line == "# artifacts: "* && $ARTIFACTS == "" ]]; then + # echo the line and use `sed` to remove the custom directive + ARTIFACTS=$(echo -e "$line" | sed 's/# artifacts: //') + elif [[ $PLATFORMS != "" && $ARTIFACTS != "" ]]; then + # break while loop once all custom directives are found + break + fi + done <"${{ matrix.dockerfile }}" + # if PLATFORMS is blank, fall back to the legacy method of reading from the `.docker_platforms` file + if [[ $PLATFORMS == "" ]]; then + # read the platforms from `.docker_platforms` + PLATFORMS=$(<.docker_platforms) + fi + # if PLATFORMS is still blank, fall back to `linux/amd64` + if [[ $PLATFORMS == "" ]]; then + PLATFORMS="linux/amd64" + fi - echo ::set-output name=branch::${BRANCH} - echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - echo ::set-output name=commit::${COMMIT} - echo ::set-output name=platforms::${PLATFORMS} - echo ::set-output name=push::${PUSH} - echo ::set-output name=tags::${TAGS} + echo "branch=${BRANCH}" >> $GITHUB_OUTPUT + echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT + echo "commit=${COMMIT}" >> $GITHUB_OUTPUT + echo "artifacts=${ARTIFACTS}" >> $GITHUB_OUTPUT + echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT + echo "push=${PUSH}" >> $GITHUB_OUTPUT + echo "tags=${TAGS}" >> $GITHUB_OUTPUT - name: Set Up QEMU uses: docker/setup-qemu-action@v2 @@ -146,9 +293,9 @@ jobs: uses: actions/cache@v3 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} + key: Docker-buildx${{ matrix.tag }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx- + Docker-buildx${{ matrix.tag }}- - name: Log in to Docker Hub if: ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets @@ -165,21 +312,73 @@ jobs: username: ${{ secrets.GH_BOT_NAME }} password: ${{ secrets.GH_BOT_TOKEN }} + - name: Build artifacts + if: ${{ steps.prepare.outputs.artifacts == 'true' }} + id: build_artifacts + uses: docker/build-push-action@v4 + with: + context: ./ + file: ${{ matrix.dockerfile }} + target: artifacts + outputs: type=local,dest=artifacts + push: false + platforms: ${{ steps.prepare.outputs.platforms }} + build-args: | + BRANCH=${{ steps.prepare.outputs.branch }} + BUILD_DATE=${{ steps.prepare.outputs.build_date }} + BUILD_VERSION=${{ needs.check_changelog.outputs.next_version }} + COMMIT=${{ steps.prepare.outputs.commit }} + tags: ${{ steps.prepare.outputs.tags }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache + - name: Build and push - uses: docker/build-push-action@v3 + id: build + uses: docker/build-push-action@v4 with: context: ./ - file: ./Dockerfile + file: ${{ matrix.dockerfile }} push: ${{ steps.prepare.outputs.push }} platforms: ${{ steps.prepare.outputs.platforms }} build-args: | BRANCH=${{ steps.prepare.outputs.branch }} - COMMIT=${{ steps.prepare.outputs.commit }} BUILD_DATE=${{ steps.prepare.outputs.build_date }} + BUILD_VERSION=${{ needs.check_changelog.outputs.next_version }} + COMMIT=${{ steps.prepare.outputs.commit }} tags: ${{ steps.prepare.outputs.tags }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + - name: Arrange Artifacts + if: ${{ steps.prepare.outputs.artifacts == 'true' }} + working-directory: artifacts + run: | + # artifacts will be in sub directories named after the docker target platform, e.g. `linux_amd64` + # so move files to the artifacts directory + # https://unix.stackexchange.com/a/52816 + find ./ -type f -exec mv -t ./ -n '{}' + + + - name: Upload Artifacts + if: ${{ steps.prepare.outputs.artifacts == 'true' }} + uses: actions/upload-artifact@v3 + with: + name: Docker${{ matrix.tag }} + path: artifacts/ + + - name: Create/Update GitHub Release + if: ${{ needs.setup_release.outputs.create_release == 'true' && steps.prepare.outputs.artifacts == 'true' }} + uses: ncipollo/release-action@v1 + with: + name: ${{ needs.setup_release.outputs.release_name }} + tag: ${{ needs.setup_release.outputs.release_tag }} + commit: ${{ needs.setup_release.outputs.release_commit }} + artifacts: "*artifacts/*" + token: ${{ secrets.GH_BOT_TOKEN }} + allowUpdates: true + body: ${{ needs.setup_release.outputs.release_body }} + discussionCategory: announcements + prerelease: ${{ needs.setup_release.outputs.pre_release }} + - name: Update Docker Hub Description if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} uses: peter-evans/dockerhub-description@v3 diff --git a/.github/workflows/issues-stale.yml b/.github/workflows/issues-stale.yml index d6e63e7..5fe1d77 100644 --- a/.github/workflows/issues-stale.yml +++ b/.github/workflows/issues-stale.yml @@ -3,19 +3,22 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# Manage stale issues and PRs. + name: Stale Issues / PRs on: schedule: - - cron: '00 00 * * *' + - cron: '00 10 * * *' jobs: stale: name: Check Stale Issues / PRs + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: Stale - uses: actions/stale@v5 + uses: actions/stale@v7 with: close-issue-message: > This issue was closed because it has been stalled for 10 days with no activity. @@ -37,7 +40,7 @@ jobs: repo-token: ${{ secrets.GH_BOT_TOKEN }} - name: Invalid Template - uses: actions/stale@v5 + uses: actions/stale@v7 with: close-issue-message: > This issue was closed because the the template was not completed after 5 days. diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 6ba4444..d7a1025 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -3,6 +3,8 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# Label and un-label actions using `../label-actions.yml`. + name: Issues on: @@ -14,9 +16,10 @@ on: jobs: label: name: Label Actions + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: Label Actions - uses: dessant/label-actions@v2 + uses: dessant/label-actions@v3 with: github-token: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 0abc26b..5824387 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -3,15 +3,20 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# Ensure PRs are made against `nightly` branch. + name: Pull Requests on: pull_request_target: types: [opened, synchronize, edited, reopened] +# no concurrency for pull_request_target events + jobs: check-pull-request: name: Check Pull Request + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - uses: Vankka/pr-target-branch-action@v2 diff --git a/.github/workflows/python-flake8.yml b/.github/workflows/python-flake8.yml index 463fb8a..19bcdb9 100644 --- a/.github/workflows/python-flake8.yml +++ b/.github/workflows/python-flake8.yml @@ -3,6 +3,8 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# Lint python files with flake8. + name: flake8 on: @@ -10,6 +12,10 @@ on: branches: [master, nightly] types: [opened, synchronize, reopened] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: flake8: runs-on: ubuntu-latest @@ -24,7 +30,8 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools flake8 + # pin flake8 before v6.0.0 due to removal of support for type comments (required for Python 2.7 type hints) + python -m pip install --upgrade pip setuptools "flake8<6" - name: Test with flake8 run: | diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml index 83de6c2..6327d5d 100644 --- a/.github/workflows/yaml-lint.yml +++ b/.github/workflows/yaml-lint.yml @@ -3,6 +3,8 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. +# Lint yaml files. + name: yaml lint on: @@ -10,12 +12,34 @@ on: branches: [master, nightly] types: [opened, synchronize, reopened] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: yaml-lint: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 + + - name: Find additional files + id: find-files + run: | + # space separated list of files + FILES=.clang-format + + # empty placeholder + FOUND="" + + for FILE in ${FILES}; do + if [ -f "$FILE" ] + then + FOUND="$FOUND $FILE" + fi + done + + echo "found=${FOUND}" >> $GITHUB_OUTPUT - name: yaml lint id: yaml-lint @@ -30,17 +54,13 @@ jobs: line-length: max: 120 truthy: - allowed-values: ['true', 'false', 'on'] # GitHub uses "on" for workflow event triggers + # GitHub uses "on" for workflow event triggers + # .clang-format file has options of "Yes" "No" that will be caught by this, so changed to "warning" + allowed-values: ['true', 'false', 'on'] check-keys: true - level: error + level: warning + file_or_dir: . ${{ steps.find-files.outputs.found }} - name: Log run: | - echo ${{ steps.yaml-lint.outputs.logfile }} - - - name: Upload logs - uses: actions/upload-artifact@v2 - if: failure() - with: - name: yamllint-logfile - path: ${{ steps.yaml-lint.outputs.logfile }} + cat "${{ steps.yaml-lint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a55c26..a2b2268 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [0.1.2] - 2023-02-19 +### Dependencies +- Bump flask from 2.2.2 to 2.2.3 +- Bump igdb-api-v4 from 0.0.5 to 0.1.0 +- Bump requests from 2.28.1 to 2.28.2 +- Bump python-dotenv from 0.20.0 to 0.21.1 +- Bump libgravatar from 1.0.0 to 1.0.3 +- Bump beautifulsoup4 from 4.11.1 to 4.11.2 +- Bump py-cord from 2.0.1 to 2.4.0 +- Bump python from 3.9.12 to 3.11.2 + ## [0.1.1] - 2022-08-20 ### Changed - Enable timeout callback for `/docs` command after 45s @@ -56,3 +67,12 @@ ## [0.0.1] - 2022-04-03 ### Added - (Misc.) Initial release + +[0.0.1]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.0.1 +[0.0.2]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.0.2 +[0.0.3]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.0.3 +[0.0.4]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.0.4 +[0.0.5]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.0.5 +[0.1.0]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.1.0 +[0.1.1]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.1.1 +[0.1.2]: https://github.com/lizardbyte/discord-bot/releases/tag/v0.1.2 diff --git a/Dockerfile b/Dockerfile index 00eeb93..a0e6b49 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.9.12-slim-bullseye +FROM python:3.11.2-slim-bullseye # Basic config ARG DAILY_TASKS=true diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 4bc5f84..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,19 +0,0 @@ -[tool.poetry] -name = "lizardbyte-discord-bot" -version = "0.1.0" -description = "Bot for LizardByte discord server" -authors = ["ReenigneArcher"] - -[tool.poetry.dependencies] -python = "^3.8" -py-cord = "2.0.1" -Flask = "2.2.2" -igdb-api-v4 = "0.0.5" -python-dotenv = "0.20.0" -requests = "2.28.1" - -[tool.poetry.dev-dependencies] - -[build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" diff --git a/requirements.txt b/requirements.txt index ac8fd2e..0654cbc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ -beautifulsoup4==4.11.1 -Flask==2.2.2 -igdb-api-v4==0.0.5 -libgravatar==1.0.0 -py-cord==2.0.1 -python-dotenv==0.20.0 -requests==2.28.1 +beautifulsoup4==4.11.2 +Flask==2.2.3 +igdb-api-v4==0.1.0 +libgravatar==1.0.3 +py-cord==2.4.0 +python-dotenv==0.21.1 +requests==2.28.2