diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..fbf7a10d --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,3 @@ +# Review workflow changes before approving any fork-triggered Actions run. +/.github/CODEOWNERS @misko +/.github/workflows/ @misko diff --git a/.github/workflows/docker-build-and-test.yml b/.github/workflows/docker-build-and-test.yml index 56aab2c8..0eb3ee00 100644 --- a/.github/workflows/docker-build-and-test.yml +++ b/.github/workflows/docker-build-and-test.yml @@ -1,4 +1,8 @@ -name: Build, Deploy and Test +name: Owner Build, Deploy and Test + +# Security boundary: this public repository's privileged Docker publishing and +# full test jobs run only for main pushes initiated by the repository owner. +# Pull requests are checked separately on GitHub-hosted runners. on: push: @@ -11,43 +15,41 @@ on: - "docs/libiio_frame_metadata_install.md" - "tests/test_libiio_dependency_contract.py" - "README.md" - pull_request: - branches: [ "main" ] - paths-ignore: - - ".github/workflows/docker-build-and-test.yml" - - ".github/workflows/libiio-packages.yml" - - "packaging/libiio/**" - - "install_spf_libiio*.sh" - - "docs/libiio_frame_metadata_install.md" - - "tests/test_libiio_dependency_contract.py" - - "README.md" + +permissions: + contents: read jobs: build: + if: github.actor == 'misko' + runs-on: [self-hosted, Linux, X64] steps: - name: Check out immutable source revision - uses: actions/checkout@v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: - ref: ${{ github.event.pull_request.head.sha || github.sha }} + ref: ${{ github.sha }} + persist-credentials: false - name: Login to Docker Hub - uses: docker/login-action@v3 + uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 with: context: . push: true tags: csmisko/ardupilotspf:latest - runs-on: self-hosted pytest: + if: github.actor == 'misko' needs: build - runs-on: self-hosted + runs-on: [self-hosted, Linux, X64] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + persist-credentials: false - name: Set up Python 3.10 - uses: actions/setup-python@v3 + uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 with: python-version: "3.10" #- name: Install system depdendencies @@ -79,9 +81,10 @@ jobs: - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names - flake8 . --count --select=E9,F63,F7,F82,F811 --show-source --statistics + # F824 remains a known repository baseline and is reported below. + flake8 . --exclude=.venv --count --select=E9,F63,F7,F82,F811 --ignore=F824 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --exclude=.venv --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - name: Test with pytest run: | python3 -m pytest diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml new file mode 100644 index 00000000..005f0cb2 --- /dev/null +++ b/.github/workflows/pr-check.yml @@ -0,0 +1,27 @@ +name: Pull Request Checks + +# Public pull-request code must remain on GitHub-hosted runners and must not +# receive deployment credentials. +on: + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 + with: + persist-credentials: false + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 + with: + python-version: "3.10" + - name: Lint Python + run: | + python -m pip install flake8 + # F824 remains a known repository baseline and is reported below. + flake8 . --exclude=.venv --count --select=E9,F63,F7,F82,F811 --ignore=F824 --show-source --statistics + flake8 . --exclude=.venv --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics