Skip to content

Commit a31a0d2

Browse files
authored
Change all references of master to main (#405)
* Change all references of master to main * optimize docker build process * fix runner type * simplify cache key * don't cache to ECR
1 parent 94bcee2 commit a31a0d2

File tree

8 files changed

+110
-82
lines changed

8 files changed

+110
-82
lines changed

.dockerignore

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,56 @@
1-
*.env
2-
git/
1+
# Git
2+
.git
3+
.github
4+
.gitignore
35

4-
build
5-
dist
6+
# Python
7+
.venv
8+
venv
9+
__pycache__
10+
*.pyc
11+
*.pyo
12+
*.pyd
13+
.Python
14+
*.so
15+
*.egg
616
*.egg-info
7-
*.egg/
17+
dist
18+
build
19+
.pytest_cache
20+
.coverage
21+
htmlcov
22+
.tox
23+
.mypy_cache
24+
.ruff_cache
25+
26+
# Environment files
27+
.env
28+
.env.*
29+
!.env.example
30+
31+
# IDE
32+
.vscode
33+
.idea
834
*.swp
35+
*.swo
36+
*~
937

10-
.tox
11-
.coverage
12-
html/*
13-
**/__pycache__
14-
**/*.pyc
15-
16-
# Development files - should not be in production
17-
.dev/
18-
src/.dev/
19-
src/.dev
20-
**/.dev/
21-
**/.dev
22-
*.sqlite3
23-
*.db
24-
db.sqlite3
25-
src/db.sqlite3
26-
**/db.sqlite3
27-
28-
# Test artifacts
29-
.pytest_cache/
30-
src/.pytest_cache/
31-
**/.pytest_cache/
32-
.coverage
33-
htmlcov/
38+
# Logs
39+
*.log
40+
41+
# Documentation
42+
*.md
43+
!README.md
44+
docs/
45+
46+
# Testing
47+
tests/
48+
*.test
49+
50+
# macOS
51+
.DS_Store
52+
53+
# Temporary files
54+
tmp/
55+
temp/
56+
*.tmp

.github/SETUP.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ After adding the secret, the workflow will automatically:
3939
- Authenticate to AWS using OIDC (no credentials stored)
4040
- Build Docker images for ARM64 platform
4141
- Push to ECR with appropriate tags:
42-
- `:staging` for non-master branches
43-
- `:prod` for master branch (after CI passes)
42+
- `:staging` for non-main branches
43+
- `:prod` for main branch (after CI passes)
4444

4545
## Testing
4646

4747
To test the setup:
4848

49-
1. **Test staging build**: Push to any branch except `master`
49+
1. **Test staging build**: Push to any branch except `main`
5050
- Should trigger Docker build and push to `:staging` tag
5151
- Check ECR repository to verify image was pushed
5252

53-
2. **Test production build**: Merge to `master` branch
53+
2. **Test production build**: Merge to `main` branch
5454
- Should run lint, test, security checks first
5555
- If all pass, should build and push to `:prod` tag
5656
- Check ECR repository to verify image was pushed

.github/workflows/ci.yml

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: CI
22

33
on:
44
push:
5-
branches: [master]
5+
branches: [main]
66
pull_request:
7-
branches: [master]
7+
branches: [main]
88

99
env:
1010
POETRY_VERSION: "2.3.0"
@@ -14,8 +14,8 @@ jobs:
1414
lint:
1515
name: Lint
1616
runs-on: ubuntu-latest
17-
# Only run on master branch pushes and PRs to master
18-
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
17+
# Only run on main branch pushes and PRs to main
18+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
1919
steps:
2020
- name: Checkout code
2121
uses: actions/checkout@v4
@@ -62,8 +62,8 @@ jobs:
6262
test:
6363
name: Test
6464
runs-on: ubuntu-latest
65-
# Only run on master branch pushes and PRs to master
66-
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
65+
# Only run on main branch pushes and PRs to main
66+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
6767
steps:
6868
- name: Checkout code
6969
uses: actions/checkout@v4
@@ -125,8 +125,8 @@ jobs:
125125
security:
126126
name: Security Scan
127127
runs-on: ubuntu-latest
128-
# Only run on master branch pushes and PRs to master
129-
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
128+
# Only run on main branch pushes and PRs to main
129+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
130130
steps:
131131
- name: Checkout code
132132
uses: actions/checkout@v4
@@ -172,10 +172,10 @@ jobs:
172172

173173
docker-build-push:
174174
name: Build and Push Docker Image
175-
runs-on: ubuntu-latest
176-
# Run on push to master (build+push) and on PRs (build only)
175+
runs-on: ubuntu-24.04-arm
176+
# Run on push to main (build+push) and on PRs (build only)
177177
if: github.event_name == 'push' || github.event_name == 'pull_request'
178-
# For master/PR, wait for CI checks to pass
178+
# For main/PR, wait for CI checks to pass
179179
needs: [ci-success]
180180
permissions:
181181
id-token: write # Required for OIDC authentication
@@ -232,7 +232,7 @@ jobs:
232232
- name: Determine Docker tag
233233
id: docker-tag
234234
run: |
235-
if [ "${{ github.ref }}" == "refs/heads/master" ]; then
235+
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
236236
echo "image=633607774026.dkr.ecr.us-east-2.amazonaws.com/back-end:prod" >> $GITHUB_OUTPUT
237237
echo "environment=Production" >> $GITHUB_OUTPUT
238238
else
@@ -260,7 +260,7 @@ jobs:
260260
uses: aws-actions/amazon-ecr-login@v2
261261

262262
- name: Build and push Docker image
263-
uses: docker/build-push-action@v5
263+
uses: docker/build-push-action@v6
264264
with:
265265
context: .
266266
target: runtime
@@ -269,8 +269,8 @@ jobs:
269269
tags: |
270270
${{ steps.docker-tag.outputs.image }}
271271
provenance: false
272-
cache-from: type=gha
273-
cache-to: type=gha,mode=max
272+
cache-from: type=gha,scope=arm64
273+
cache-to: type=gha,mode=max,scope=arm64
274274

275275
- name: Output image URI
276276
if: steps.can-push.outputs.push == 'true'
@@ -286,20 +286,20 @@ jobs:
286286
# Always run to satisfy docker-build-push dependency
287287
if: always()
288288
steps:
289-
- name: Check all jobs passed (master/PR only)
290-
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/master'
289+
- name: Check all jobs passed (main/PR only)
290+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
291291
run: |
292-
# Check if jobs were skipped (non-master) or failed
292+
# Check if jobs were skipped (non-main) or failed
293293
if [[ "${{ needs.lint.result }}" == "skipped" ]]; then
294-
echo "Lint job was skipped - this should not happen on master/PR"
294+
echo "Lint job was skipped - this should not happen on main/PR"
295295
exit 1
296296
fi
297297
if [[ "${{ needs.lint.result }}" != "success" ]]; then
298298
echo "Lint job failed"
299299
exit 1
300300
fi
301301
if [[ "${{ needs.test.result }}" == "skipped" ]]; then
302-
echo "Test job was skipped - this should not happen on master/PR"
302+
echo "Test job was skipped - this should not happen on main/PR"
303303
exit 1
304304
fi
305305
if [[ "${{ needs.test.result }}" != "success" ]]; then
@@ -308,7 +308,7 @@ jobs:
308308
fi
309309
# Security is informational, doesn't fail CI
310310
echo "All required jobs passed!"
311-
- name: Pass through for non-master branches
312-
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/master'
311+
- name: Pass through for non-main branches
312+
if: github.event_name != 'pull_request' && github.ref != 'refs/heads/main'
313313
run: |
314-
echo "Skipping CI checks for non-master branch (staging build will proceed)"
314+
echo "Skipping CI checks for non-main branch (staging build will proceed)"

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ High level overview of upcoming Operation Code goals. This is the source of upc
172172

173173
## Working On Your Issue
174174

175-
* Please first **read** Operation Code's [guidelines for working an issue](https://github.com/OperationCode/operationcode/blob/master/CONTRIBUTING.md#guidelines-for-working-an-issue)
175+
* Please first **read** Operation Code's [guidelines for working an issue](https://github.com/OperationCode/operationcode/blob/main/CONTRIBUTING.md#guidelines-for-working-an-issue)
176176

177177
* From the forked and cloned repository on your environment, you can now create a [feature branch](http://nvie.com/posts/a-successful-git-branching-model/). It is a good idea to name your branch after the issue it is attached to.
178178

@@ -188,10 +188,10 @@ git branch
188188

189189
* Once you have finished your work, head over to **Operation Code**'s main GitHub page, and make a pull request. More information about pull requests can be found in the next section.
190190

191-
* To return to your main `master` branch, type the following in the terminal:
191+
* To return to your main `main` branch, type the following in the terminal:
192192

193193
```bash
194-
git checkout master
194+
git checkout main
195195
```
196196

197197
</details>
@@ -202,10 +202,10 @@ git checkout master
202202
<summary>Click to Expand</summary>
203203
Some issues take awhile to code a solution for. It is very normal to take a large amount of time to turn in
204204
well-written work that resolves an issue! In the meantime, there could be many other people contributing to the
205-
code base. Since we use Git, you'll want to keep you project up-to-date with the `master` branch so there are no
205+
code base. Since we use Git, you'll want to keep you project up-to-date with the `main` branch so there are no
206206
[merge conflicts](https://help.github.com/articles/about-merge-conflicts/) to resolve when you make your pull request.
207207
<ol>
208-
<li> <a href="https://help.github.com/articles/syncing-a-fork/">Keep your fork in sync with Operation Code's master branch.</a></li>
208+
<li> <a href="https://help.github.com/articles/syncing-a-fork/">Keep your fork in sync with Operation Code's main branch.</a></li>
209209
</ol>
210210
</details>
211211

@@ -291,7 +291,7 @@ Download and install Git for Windows from https://git-scm.com/download/win
291291

292292
Download the latest version of python at https://www.python.org/downloads/, (3.7.3 at time of writing)
293293

294-
Follow the steps found in the [Quick Start Guide](https://github.com/OperationCode/back-end/blob/master/README.md#quick-start)
294+
Follow the steps found in the [Quick Start Guide](https://github.com/OperationCode/back-end/blob/main/README.md#quick-start)
295295

296296
Occasionally you will deal with path issues this is fixed within windows by adding the appropriate key value pair to the path.
297297

Dockerfile

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
FROM python:3.12-slim AS builder
77

88
# Install build dependencies required for compiling Python packages
9-
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
10+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
11+
rm -f /etc/apt/apt.conf.d/docker-clean && \
12+
apt-get update && apt-get install -y --no-install-recommends \
1013
build-essential \
1114
libpq-dev \
12-
curl \
13-
&& rm -rf /var/lib/apt/lists/*
15+
curl
1416

1517
# Install Poetry
1618
ENV POETRY_VERSION=2.3.0 \
@@ -20,7 +22,8 @@ ENV POETRY_VERSION=2.3.0 \
2022
POETRY_VIRTUALENVS_CREATE=1 \
2123
POETRY_CACHE_DIR=/tmp/poetry_cache
2224

23-
RUN curl -sSL https://install.python-poetry.org | python3 - && \
25+
RUN --mount=type=cache,target=/root/.cache \
26+
curl -sSL https://install.python-poetry.org | python3 - && \
2427
ln -s /opt/poetry/bin/poetry /usr/local/bin/poetry
2528

2629
WORKDIR /app
@@ -52,13 +55,14 @@ LABEL org.opencontainers.image.description="Operation Code Backend - Development
5255
LABEL org.opencontainers.image.licenses="MIT"
5356

5457
# Install runtime dependencies
55-
RUN apt-get update && apt-get install -y --no-install-recommends \
58+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
59+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
60+
rm -f /etc/apt/apt.conf.d/docker-clean && \
61+
apt-get update && apt-get install -y --no-install-recommends \
5662
libpq5 \
5763
curl \
5864
wget \
59-
&& apt-get upgrade -y \
60-
&& rm -rf /var/lib/apt/lists/* \
61-
&& apt-get clean
65+
&& apt-get upgrade -y
6266

6367
# Create non-root user for security
6468
RUN groupadd -r appuser && \
@@ -100,13 +104,14 @@ LABEL org.opencontainers.image.description="Operation Code Backend - Django API"
100104
LABEL org.opencontainers.image.licenses="MIT"
101105

102106
# Install only runtime dependencies (no build tools)
103-
RUN apt-get update && apt-get install -y --no-install-recommends \
107+
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
108+
--mount=type=cache,target=/var/lib/apt,sharing=locked \
109+
rm -f /etc/apt/apt.conf.d/docker-clean && \
110+
apt-get update && apt-get install -y --no-install-recommends \
104111
libpq5 \
105112
curl \
106113
wget \
107-
&& apt-get upgrade -y \
108-
&& rm -rf /var/lib/apt/lists/* \
109-
&& apt-get clean
114+
&& apt-get upgrade -y
110115

111116
# Create non-root user for security
112117
RUN groupadd -r appuser && \

MAINTAINERS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This file lists how the Operation Code Back End project is maintained. When making changes to the system, this file tells you who needs to review your contribution - you need a simple majority of maintainers for the relevant subsystems to provide a 👍 on your pull request. Additionally, you need to not receive a veto from a lieutenant or the project lead.
44

5-
Check out [how Operation Code Open Source projects are maintained](https://github.com/OperationCode/START_HERE/blob/master/open_source_maintenance_policy.md) for details on the process, how to become a maintainer, lieutenant, or the project lead.
5+
Check out [how Operation Code Open Source projects are maintained](https://github.com/OperationCode/START_HERE/blob/main/open_source_maintenance_policy.md) for details on the process, how to become a maintainer, lieutenant, or the project lead.
66

77
# Project Lead
88

OPS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ The backend is deployed to AWS ECS (Elastic Container Service) with separate sta
88

99
Docker images are automatically built and pushed to AWS ECR via GitHub Actions:
1010

11-
- **PR branches** (any branch except `master`): Automatically builds and pushes to `:staging` tag
12-
- **Master branch**: Automatically builds and pushes to `:prod` tag after CI checks pass
11+
- **PR branches** (any branch except `main`): Automatically builds and pushes to `:staging` tag
12+
- **main branch**: Automatically builds and pushes to `:prod` tag after CI checks pass
1313

1414
The automated builds use AWS OIDC for secure authentication (no long-lived credentials).
1515

@@ -208,8 +208,8 @@ After setup, the GitHub Actions workflow will automatically:
208208
- Push images to ECR with appropriate tags (`:staging` or `:prod`)
209209

210210
You can verify by:
211-
1. Pushing a commit to a non-master branch (should push `:staging`)
212-
2. Merging to master (should push `:prod` after tests pass)
211+
1. Pushing a commit to a non-main branch (should push `:staging`)
212+
2. Merging to main (should push `:prod` after tests pass)
213213
3. Checking ECR repository for new images
214214

215215
## Security Best Practices

0 commit comments

Comments
 (0)