Skip to content

Commit 6962927

Browse files
committed
fix: linting and copilot setup
- ensure credentials are not persisted past checkout of code - add zizmor.yml file to linters to allow pull_request_target in actions for auto-labeler to work on fork pull requests - add trivy.yml file to linters to ignore mypy_cache directory - add HEALTHCHECK and non-root user to Dockerfile - setup copilot files Signed-off-by: jmeridth <[email protected]>
1 parent 7f1ca64 commit 6962927

File tree

10 files changed

+103
-2
lines changed

10 files changed

+103
-2
lines changed

.github/copilot-instructions.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copilot Instructions
2+
3+
This is a GitHub Action identifies and reports repositories with no activity for configurable amount of time, in order to surface inactive repos to be considered for archival.
4+
5+
## Code Standards
6+
7+
### Required Before Each Commit
8+
9+
- Run `make lint` before committing any changes to ensure proper code linting and formatting.
10+
11+
### Development Flow
12+
13+
- Lint: `make lint`
14+
- Test: `make test`
15+
16+
## Repository Structure
17+
18+
- `Makefile`: Contains commands for linting, testing, and other tasks
19+
- `requirements.txt`: Python dependencies for the project
20+
- `requirements-test.txt`: Python dependencies for testing
21+
- `README.md`: Project documentation and setup instructions
22+
- `setup.py`: Python package setup configuration
23+
- `test_*.py`: Python test files matching the naming convention for test discovery
24+
25+
## Key Guidelines
26+
27+
1. Follow Python best practices and idiomatic patterns
28+
2. Maintain existing code structure and organization
29+
3. Write unit tests for new functionality.
30+
4. Document changes to environment variables in the `README.md` file.

.github/linters/trivy.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
scan:
2+
skip-dirs:
3+
- .mypy_cache

.github/linters/zizmor.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rules:
2+
dangerous-triggers: # to allow pull_request_target for auto-labelling fork pull requests
3+
ignore:
4+
- auto-labeler.yml
5+
- pr-title.yml
6+
- release.yml
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Automatically run the setup steps when they are changed to allow for easy validation, and
4+
# allow manual testing through the repository's "Actions" tab
5+
on:
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- .github/workflows/copilot-setup-steps.yml
10+
pull_request:
11+
paths:
12+
- .github/workflows/copilot-setup-steps.yml
13+
14+
# Set the permissions to the lowest permissions possible needed for your steps.
15+
# Copilot will be given its own token for its operations.
16+
permissions:
17+
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
18+
contents: read
19+
20+
jobs:
21+
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
22+
copilot-setup-steps:
23+
runs-on: ubuntu-latest
24+
25+
# You can define any steps you want, and they will run before the agent starts.
26+
# If you do not check out your code, Copilot will do this for you.
27+
steps:
28+
- name: Checkout code
29+
uses: actions/[email protected]
30+
with:
31+
persist-credentials: false
32+
33+
- name: Set up Python
34+
uses: actions/[email protected]
35+
with:
36+
python-version: 3.12
37+
38+
- name: Install dependencies
39+
run: |
40+
pip install -r requirements.txt -r requirements-test.txt

.github/workflows/docker-image.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@ jobs:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/[email protected]
18+
with:
19+
persist-credentials: false
1820
- name: Build the Docker image
1921
run: docker build . --file Dockerfile --platform linux/amd64 --tag stale_repos:"$(date +%s)"

.github/workflows/linter.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ jobs:
2323
# Full git history is needed to get a proper
2424
# list of changed files within `super-linter`
2525
fetch-depth: 0
26+
persist-credentials: false
27+
- name: Setup Python
28+
uses: actions/[email protected]
29+
with:
30+
python-version: "3.12"
2631
- name: Install dependencies
2732
run: |
2833
python -m pip install --upgrade pip

.github/workflows/major-version-updater.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
with:
2222
fetch-tags: true
2323
ref: ${{ github.event.inputs.TAG_NAME || github.ref }}
24+
persist-credentials: false
2425
- name: version
2526
id: version
2627
run: |

.github/workflows/python-package.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ jobs:
2020
python-version: [3.11, 3.12, 3.13]
2121
steps:
2222
- uses: actions/[email protected]
23+
with:
24+
persist-credentials: false
2325
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v5.6.0
26+
uses: actions/setup-python@v6.0.0
2527
with:
2628
python-version: ${{ matrix.python-version }}
2729
- name: Install dependencies

.github/workflows/use-action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ jobs:
2020
steps:
2121
- name: Checkout code
2222
uses: actions/[email protected]
23+
with:
24+
persist-credentials: false
2325
- name: Run stale_repos tool
2426
uses: docker://ghcr.io/github/stale_repos:v3
2527
env:

Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ COPY requirements.txt *.py /action/workspace/
1616
RUN python3 -m pip install --no-cache-dir -r requirements.txt \
1717
&& apt-get -y update \
1818
&& apt-get -y install --no-install-recommends git=1:2.47.3-0+deb13u1 \
19-
&& rm -rf /var/lib/apt/lists/*
19+
&& rm -rf /var/lib/apt/lists/* \
20+
&& addgroup --system appuser \
21+
&& adduser --system --ingroup appuser --home /action/workspace --disabled-login appuser \
22+
&& chown -R appuser:appuser /action/workspace
23+
24+
# Run the action as a non-root user
25+
USER appuser
26+
27+
# Add a simple healthcheck to satisfy container scanners
28+
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
29+
CMD python3 -c "import os,sys; sys.exit(0 if os.path.exists('/action/workspace/stale_repos.py') else 1)"
2030

2131
CMD ["/action/workspace/stale_repos.py"]
2232
ENTRYPOINT ["python3", "-u"]

0 commit comments

Comments
 (0)