diff --git a/.github/workflows/add-reviewer-label.yaml b/.github/workflows/add-reviewer-label.yaml new file mode 100644 index 0000000000..92a97d22cf --- /dev/null +++ b/.github/workflows/add-reviewer-label.yaml @@ -0,0 +1,21 @@ +# Add `needs-starcraft-review` if starcraft-reviewers is added as a reviewer + +name: add-reviewer-label + +on: + pull_request: + types: + - review_requested + +jobs: + add-reviewer-label: + runs-on: ubuntu-latest + steps: + - name: Add 'needs-starcraft-review' label + uses: octokit/request-action@v2.3.1 + with: + route: POST /repos/${{ github.repository }}/issues/${{ github.event.number }}/labels + mediaType: 'application/vnd.github.v3+json' + labels: '["needs-starcraft-review"]' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/add-reviewers.yaml b/.github/workflows/add-reviewers.yaml new file mode 100644 index 0000000000..4a56ffe1b3 --- /dev/null +++ b/.github/workflows/add-reviewers.yaml @@ -0,0 +1,42 @@ +# If there are not 2 reviews, re-add starcraft-reviewers when reviewed by the starcraft-reviewers team +# Otherwise, drop the `need-starcraft-review` label + +name: add-reviewer + +on: + pull_request_review: + types: [submitted] + +jobs: + add-reviewer: + runs-on: ubuntu-latest + + steps: + - name: check number of reviews + id: check-reviews + uses: octokit/request-action@v2.3.1 + with: + route: GET /repos/${{ github.repository }}/pulls/${{ github.event.number }}/reviews + mediaType: 'application/vnd.github.v3+json' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: re-add team if there are not enough reviews + if: steps.check-reviews.outputs.data | fromJson | length < 2 + uses: octokit/request-action@v2.3.1 + with: + route: POST /repos/${{ github.repository }}/pulls/${{ github.event.number }}/requested_reviewers + mediaType: 'application/vnd.github.v3+json' + reviewers: starcraft-reviewers + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: drop label if there are enough reviews + if: steps.check-reviews.outputs.data | fromJson | length >= 2 + uses: octokit/request-action@v2.3.1 + with: + route: DELETE /repos/${{ github.repository }}/issues/${{ github.event.number }}/labels + mediaType: 'application/vnd.github.v3+json' + labels: '["needs-starcraft-review"]' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml deleted file mode 100644 index dbc67234b5..0000000000 --- a/.github/workflows/publish.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: - - "feature/**" - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: Decision to Publish - id: decisions - run: | - # Secrets cannot be used in conditionals, so this is our dance: - # https://github.com/actions/runner/issues/520 - if [[ -n "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }}" ]]; then - echo PUBLISH=true >> $GITHUB_OUTPUT - else - echo PUBLISH= >> $GITHUB_OUTPUT - fi - - - if: steps.decisions.outputs.PUBLISH == 'true' - name: Checkout Snapcraft - uses: actions/checkout@v4 - with: - # Fetch all of history so Snapcraft can determine its own version from git. - fetch-depth: 0 - - - if: steps.decisions.outputs.PUBLISH == 'true' - uses: snapcore/action-build@v1 - name: Build Snapcraft Snap - id: build - with: - snapcraft-channel: latest/candidate - - - if: steps.decisions.outputs.PUBLISH == 'true' - name: Verify Snapcraft Snap - run: | - # Make sure it is installable. - sudo snap install --dangerous --classic ${{ steps.build.outputs.snap }} - - - name: Get branch name - id: vars - run: | - if [[ "${{ github.event_name }}" == "pull_request" ]] - then - echo "branch=pr-${{ github.event.number }}" >> "$GITHUB_OUTPUT" - else - branch=$(echo ${GITHUB_REF#refs/*/} | sed -e 's|feature/\(.*\)|\1|') - echo "branch=$branch" >> "$GITHUB_OUTPUT" - fi - - - name: Publish feature branch to edge/${{ steps.vars.outputs.branch }} - if: steps.decisions.outputs.PUBLISH == 'true' - uses: snapcore/action-publish@v1 - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_CREDENTIALS }} - with: - snap: ${{ steps.build.outputs.snap }} - release: edge/${{ steps.vars.outputs.branch }} diff --git a/.github/workflows/spread.yml b/.github/workflows/spread.yml deleted file mode 100644 index 4bcfaa18e8..0000000000 --- a/.github/workflows/spread.yml +++ /dev/null @@ -1,124 +0,0 @@ -name: Spread Tests - -on: [pull_request] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout snapcraft - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Build snapcraft snap - id: build-snapcraft - uses: snapcore/action-build@v1 - - - name: Upload snapcraft snap - uses: actions/upload-artifact@v4 - with: - name: snap - path: ${{ steps.build-snapcraft.outputs.snap }} - - - name: Verify snapcraft snap - run: | - sudo snap install --dangerous --classic ${{ steps.build-snapcraft.outputs.snap }} - - integration-spread-tests: - runs-on: [spread-installed] - needs: build - strategy: - # FIXME: enable fail-fast mode once spread can cancel an executing job. - # Disable fail-fast mode as it doesn't function with spread. It seems - # that cancelling tasks requires short, interruptible actions and - # interrupting spread, notably, does not work today. As such disable - # fail-fast while we tackle that problem upstream. - fail-fast: false - matrix: - spread-jobs: - - google:ubuntu-20.04-64 - - google:ubuntu-22.04-64 - - google:ubuntu-24.04-64 - - steps: - - name: Checkout snapcraft - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: true - - - name: Download snapcraft snap - uses: actions/download-artifact@v4 - with: - name: snap - path: tests - - - name: Run spread - env: - SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }} - UA_TOKEN: ${{ secrets.UA_TOKEN }} - run: spread ${{ matrix.spread-jobs }} - - - name: Discard spread workers - if: always() - run: | - shopt -s nullglob - for r in .spread-reuse.*.yaml; do - spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')" - done - - integration-spread-tests-store: - runs-on: [spread-installed] - needs: build - strategy: - # FIXME: enable fail-fast mode once spread can cancel an executing job. - # Disable fail-fast mode as it doesn't function with spread. It seems - # that cancelling tasks requires short, interruptible actions and - # interrupting spread, notably, does not work today. As such disable - # fail-fast while we tackle that problem upstream. - fail-fast: false - - steps: - - name: Decision to Run - id: decisions - run: | - # Secrets cannot be used in conditionals, so this is our dance: - # https://github.com/actions/runner/issues/520 - if [[ -n "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING }}" ]]; then - echo RUN=true >> $GITHUB_OUTPUT - else - echo RUN= >> $GITHUB_OUTPUT - fi - - - if: steps.decisions.outputs.RUN == 'true' - name: Checkout snapcraft - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: true - - - if: steps.decisions.outputs.RUN == 'true' - name: Download snapcraft snap - uses: actions/download-artifact@v4 - with: - name: snap - path: tests - - - if: steps.decisions.outputs.RUN == 'true' - name: Run spread - env: - SPREAD_GOOGLE_KEY: ${{ secrets.SPREAD_GOOGLE_KEY }} - SNAPCRAFT_STORE_CREDENTIALS_STAGING: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING }}" - SNAPCRAFT_STORE_CREDENTIALS_STAGING_CANDID: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING_CANDID }}" - SNAPCRAFT_STORE_CREDENTIALS_STAGING_LEGACY: "${{ secrets.SNAPCRAFT_STORE_CREDENTIALS_STAGING_LEGACY }}" - run: spread google:ubuntu-22.04-64:tests/spread/general/store - - - name: Discard spread workers - if: always() - run: | - shopt -s nullglob - for r in .spread-reuse.*.yaml; do - spread -discard -reuse-pid="$(echo "$r" | grep -o -E '[0-9]+')" - done diff --git a/.github/workflows/tox.yaml b/.github/workflows/tox.yaml deleted file mode 100644 index dd60a5c926..0000000000 --- a/.github/workflows/tox.yaml +++ /dev/null @@ -1,94 +0,0 @@ -name: Tox -on: - push: - branches: - - "main" - - "snapcraft/7.0" - - "release/*" - - "hotfix/*" - pull_request: - -jobs: - linters: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install dependencies - run: | - echo "::group::Begin snap install" - echo "Installing snaps in the background while running apt and pip..." - sudo snap install --no-wait --classic pyright --revision 735 # version 1.1.344 - sudo snap install --no-wait shellcheck ruff - echo "::endgroup::" - echo "::group::apt-get update" - sudo apt-get update - echo "::endgroup::" - echo "::group::apt-get install..." - sudo apt-get install --yes libapt-pkg-dev libyaml-dev xdelta3 - echo "::endgroup::" - echo "::group::pip install" - python -m pip install 'tox<5.0' tox-gh - echo "::endgroup::" - echo "::group::Create virtual environments for linting processes." - tox run --colored yes -m lint build-docs --notest - echo "::endgroup::" - echo "::group::Build docs." - tox run --colored yes -e build-docs - echo "::endgroup::" - echo "::group::Wait for snap to complete" - snap watch --last=install - echo "::endgroup::" - - name: Run Linters - run: tox run --colored yes --skip-pkg-install -m lint - tests: - strategy: - fail-fast: false # Run all the tests to their conclusions. - matrix: - platform: [ubuntu-22.04] - python_version: ["3.10"] - include: - - python_version: "3.10" - tox_python: py310 - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python version ${{ matrix.python_version }} on ${{ matrix.platform }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python_version }} - - name: Install dependencies - run: | - echo "::group::apt-get update" - sudo apt-get update - echo "::endgroup::" - echo "::group::apt-get install..." - sudo apt-get install -y libapt-pkg-dev libyaml-dev xdelta3 - echo "::endgroup::" - echo "::group::pip install" - python -m pip install 'tox<5.0' tox-gh - echo "::endgroup::" - mkdir -p results - - name: Setup Tox environments - run: tox run-parallel --parallel auto --parallel-no-spinner --parallel-live --colored yes -e test-${{ matrix.tox_python }},test-legacy-${{ matrix.tox_python }} --notest - - name: Test with tox - run: tox run --skip-pkg-install --result-json results/tox-${{ matrix.platform }}.json --colored yes -e test-${{ matrix.tox_python }},test-legacy-${{ matrix.tox_python }} - - name: Upload code coverage - uses: codecov/codecov-action@v3 - with: - directory: ./results/ - files: coverage*.xml - - name: Upload test results - if: success() || failure() - uses: actions/upload-artifact@v4 - with: - name: test-results-${{ matrix.platform }} - path: results/