Skip to content

Commit ec46965

Browse files
feat: .asdfrcとCI/CDパイプラインの設定を追加
- .asdfrcファイルを新規作成し、Pythonビルドのキャッシュ設定を追加 - CI/CDパイプラインのジョブ名を修正し、ユニットテストジョブの設定を更新 - キャッシュパスに.asdfを追加し、不要なコードを削除
1 parent 7db6fc2 commit ec46965

File tree

2 files changed

+44
-37
lines changed

2 files changed

+44
-37
lines changed

.asdfrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
legacy_version_file = yes
2+
use_release_candidates = no
3+
always_keep_download = yes
4+
plugin_repository_last_check_duration = 60
5+
disable_plugin_short_name_repository = no
6+
7+
# キャッシュ設定
8+
export PYTHON_BUILD_CACHE_PATH=${ASDF_DATA_DIR:-$HOME/.asdf}/cache/python-build

.github/workflows/ci.yml

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
run: |
4444
asdf plugin add python
4545
asdf install
46+
ls -la
4647
4748
- name: Setup uv
4849
run: |
@@ -53,6 +54,7 @@ jobs:
5354
uses: actions/cache@v4
5455
with:
5556
path: |
57+
.asdf
5658
~/.cache/pip
5759
~/.cache/uv
5860
~/.cargo
@@ -81,6 +83,7 @@ jobs:
8183
uses: actions/cache@v4
8284
with:
8385
path: |
86+
.asdf
8487
~/.cache/pip
8588
~/.cache/uv
8689
~/.cargo
@@ -106,7 +109,7 @@ jobs:
106109
uv run ruff format --check .
107110
108111
# ユニットテストジョブ
109-
test:
112+
unittest:
110113
name: Unit Tests
111114
runs-on: ubuntu-latest
112115
needs: prepare
@@ -123,6 +126,7 @@ jobs:
123126
uses: actions/cache@v4
124127
with:
125128
path: |
129+
.asdf
126130
~/.cache/pip
127131
~/.cache/uv
128132
~/.cargo
@@ -146,15 +150,8 @@ jobs:
146150
run: |
147151
uv run pytest modules/api/tests/ -v --cov=modules/api --cov-report=xml
148152
149-
- name: Upload coverage reports
150-
uses: codecov/codecov-action@v5
151-
with:
152-
file: ./coverage.xml
153-
flags: unittests
154-
name: codecov-umbrella
155-
156153
# SCAチェックジョブ(Trivy)
157-
sca:
154+
sca_trivy:
158155
name: SCA (Trivy)
159156
runs-on: ubuntu-latest
160157
needs: prepare
@@ -169,9 +166,9 @@ jobs:
169166
scan-ref: "."
170167
trivy-config: trivy-config.yaml
171168

172-
# SASTチェックジョブ(CodeQL + CodeGuru Security)
173-
sast:
174-
name: SAST (CodeQL + CodeGuru)
169+
# SASTチェックジョブ(CodeGuru Security)
170+
sast_code_guru:
171+
name: SAST (CodeGuru)
175172
runs-on: ubuntu-latest
176173
needs: prepare
177174
environment: production
@@ -183,36 +180,17 @@ jobs:
183180
- name: Checkout code
184181
uses: actions/checkout@v5
185182

186-
- name: Initialize CodeQL
187-
uses: github/codeql-action/init@v3
188-
with:
189-
languages: python
190-
191183
- name: Restore cache
192184
uses: actions/cache@v4
193185
with:
194186
path: |
187+
.asdf
195188
~/.cache/pip
196189
~/.cache/uv
197190
~/.cargo
198191
~/.local/bin
199192
key: ${{ needs.prepare.outputs.cache-key }}
200193

201-
- name: Setup asdf
202-
uses: asdf-vm/actions/setup@v4
203-
204-
- name: Install tools via asdf
205-
run: |
206-
asdf plugin add python
207-
208-
- name: Setup uv
209-
run: |
210-
curl -LsSf https://astral.sh/uv/install.sh | sh
211-
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
212-
213-
- name: Perform CodeQL Analysis
214-
uses: github/codeql-action/analyze@v3
215-
216194
- name: Configure AWS credentials via OIDC
217195
# GitHub OIDCを使ってIAMロールを引き受ける
218196
uses: aws-actions/configure-aws-credentials@v4
@@ -224,8 +202,8 @@ jobs:
224202
run: |
225203
SCAN_NAME="${{ env.CICD_TOOL }}-${{ env.STAGE_NAME }}-sast-$(date +%s)"
226204
echo "Running CodeGuru Security SAST scan: $SCAN_NAME"
227-
zip -r /tmp/source-code.zip . -x "*.git*" "node_modules/*" "*.pyc" "__pycache__/*" ".venv/*"
228-
bash ./cicd/scripts/run_codeguru_security.sh $SCAN_NAME /tmp/source-code.zip ${{ env.AWS_REGION }}
205+
zip -r /tmp/source-code.zip . -x "*.git*" "*.pyc" "__pycache__/*" ".venv/*" ".asdf/*"
206+
bash ./cicd/scripts/codeguru.sh $SCAN_NAME /tmp/source-code.zip ${{ env.AWS_REGION }}
229207
230208
# 脆弱性チェック
231209
if [ -f "$SCAN_NAME.json" ]; then
@@ -241,11 +219,32 @@ jobs:
241219
fi
242220
fi
243221
222+
sast_codeql:
223+
name: SAST (CodeQL)
224+
runs-on: ubuntu-latest
225+
needs: prepare
226+
environment: production
227+
permissions:
228+
id-token: write
229+
contents: read
230+
security-events: write
231+
steps:
232+
- name: Checkout code
233+
uses: actions/checkout@v5
234+
235+
- name: Initialize CodeQL
236+
uses: github/codeql-action/init@v3
237+
with:
238+
languages: python
239+
240+
- name: Perform CodeQL Analysis
241+
uses: github/codeql-action/analyze@v3
242+
244243
# AWS Lambdaデプロイジョブ
245244
deploy_lambda:
246245
name: Deploy to AWS Lambda
247246
runs-on: ubuntu-latest
248-
needs: [lint, test, sca, sast]
247+
needs: [lint, unittest, sca_trivy, sast_code_guru, sast_codeql]
249248
environment: production
250249
permissions:
251250
id-token: write
@@ -293,7 +292,7 @@ jobs:
293292
deploy_ec2:
294293
name: Deploy to EC2 (Blue/Green)
295294
runs-on: ubuntu-latest
296-
needs: [lint, test, sca, sast]
295+
needs: [lint, unittest, sca_trivy, sast_code_guru, sast_codeql]
297296
environment: production
298297
permissions:
299298
id-token: write
@@ -314,7 +313,7 @@ jobs:
314313
- name: Create deployment package
315314
run: |
316315
zip -r deployment-package.zip . \
317-
-x "*.git*" "node_modules/*" "*.pyc" "__pycache__/*" ".venv/*" \
316+
-x "*.git*" "*.pyc" "__pycache__/*" ".venv/*" ".asdf/*" \
318317
"cdk.out/*" "*.zip"
319318
320319
- name: Upload to S3

0 commit comments

Comments
 (0)