Skip to content

Commit e004a01

Browse files
committed
ci: Modernize GitHub Actions workflows
Update deprecated runners and EOL Python versions: - Replace macos-12 (removed by GitHub) with macos-13 - Drop Python 3.8 (EOL Oct 2024) and 3.9 (EOL Oct 2025) - Add Python 3.12 to test matrix - Bump all actions to v4 (checkout, setup-python, setup-node, cache, upload-artifact, download-artifact) - Remove unnecessary Python matrix from cd.yml delivery-python - Add unique artifact names to prevent upload-artifact@v4 conflicts
1 parent 1672f7b commit e004a01

6 files changed

Lines changed: 85 additions & 73 deletions

File tree

.github/workflows/cd.yml

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
# Continuous Delivery (Release)
32
name: cd
43

@@ -12,8 +11,8 @@ jobs:
1211
name: Prepare for NPM
1312
runs-on: ubuntu-latest
1413
steps:
15-
- uses: actions/checkout@v3
16-
- uses: actions/setup-node@v3
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
1716
with:
1817
node-version: 20
1918
registry-url: https://registry.npmjs.org/
@@ -28,47 +27,44 @@ jobs:
2827
npm pack
2928
- name: Upload NPM Artifacts
3029
id: upload_npm
31-
uses: actions/upload-artifact@v3
30+
uses: actions/upload-artifact@v4
3231
with:
3332
name: package-npm
3433
path: cfn-rpdk-${{ env.VERSION }}.tgz
3534

3635
delivery-python:
3736
name: Prepare for PyPI
3837
runs-on: ubuntu-latest
39-
strategy:
40-
matrix:
41-
python: [3.8]
4238
steps:
43-
- uses: actions/checkout@v3
44-
- name: Setup Python ${{ matrix.python }}
45-
uses: actions/setup-python@v4
39+
- uses: actions/checkout@v4
40+
- name: Setup Python
41+
uses: actions/setup-python@v5
4642
with:
47-
python-version: ${{ matrix.python }}
43+
python-version: "3.12"
4844
- name: Install Dependencies and Package Project
4945
id: installing
5046
run: |
5147
python -m pip install --upgrade pip setuptools wheel
5248
python3 setup.py sdist bdist_wheel
53-
- uses: actions/upload-artifact@v3
49+
- uses: actions/upload-artifact@v4
5450
with:
55-
name: dist-py${{ matrix.python }}
51+
name: dist-python
5652
path: dist
5753

5854
delivery-github:
5955
name: Delivery to GitHub
6056
needs: [delivery-nodejs, delivery-python]
6157
runs-on: ubuntu-latest
6258
steps:
63-
- uses: actions/checkout@v3
59+
- uses: actions/checkout@v4
6460
- name: Download NPM Artifacts
65-
uses: actions/download-artifact@v3
61+
uses: actions/download-artifact@v4
6662
with:
6763
name: package-npm
68-
- name: Download Python 3.8 Artifacts
69-
uses: actions/download-artifact@v3
64+
- name: Download Python Artifacts
65+
uses: actions/download-artifact@v4
7066
with:
71-
name: dist-py3.8
67+
name: dist-python
7268
path: dist/
7369
- name: List Artifacts
7470
run: |

.github/workflows/ci.yml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
---
21
# Continous Integration
32
name: ci
43

@@ -8,17 +7,33 @@ jobs:
87
build:
98
runs-on: ubuntu-latest
109
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
fetch-depth: 0
1113
- uses: actions/setup-python@v5
1214
with:
1315
python-version: 3.9
16+
- uses: actions/setup-node@v4
17+
with:
18+
node-version: 20
19+
cache: 'npm'
20+
- name: Install Dependencies
21+
run: |
22+
pip install --upgrade pip setuptools
23+
pip install pre-commit
24+
npm ci --include=optional
25+
npm run build
26+
- name: Run Linting
27+
run: |
28+
pre-commit run --all-files --verbose
1429
os_build:
1530
runs-on: ${{ matrix.os }}
1631
strategy:
1732
matrix:
1833
os:
1934
- ubuntu-latest
20-
- macos-12 # Later versions of ARM-based macOS runners fail because the hypervisor framework required for Docker is not supported
21-
python: [ "3.8", "3.9", "3.10", "3.11"]
35+
- macos-13
36+
python: [ "3.10", "3.11", "3.12"]
2237
node: [ 20 ]
2338
env:
2439
SAM_CLI_TELEMETRY: "0"
@@ -30,14 +45,14 @@ jobs:
3045
PIP_LOG_FILE: /tmp/pip.log
3146
HOMEBREW_NO_AUTO_UPDATE: 1
3247
steps:
33-
- uses: actions/checkout@v3
48+
- uses: actions/checkout@v4
3449
- name: Update Homebrew and save docker version
3550
if: runner.os == 'macOS'
3651
run: |
3752
brew tap homebrew/core
3853
cat "$(brew --repository)/Library/Taps/homebrew/homebrew-core/Formula/d/docker.rb" > .github/brew-formulae
3954
- name: Configure Homebrew docker cache files
40-
uses: actions/cache@v3
55+
uses: actions/cache@v4
4156
if: runner.os == 'macOS'
4257
with:
4358
path: |
@@ -51,18 +66,12 @@ jobs:
5166
run: |
5267
brew install docker --cask
5368
brew install colima
54-
# Docker engine is no longer available because of licensing
55-
# Alternative Colima is part of the github macOS runner
56-
# SAM v1.47.0+ needed for colima support, unable to use Python 3.6
5769
colima start
58-
# Ensure colima is configured for later user
5970
echo "DOCKER_HOST=unix://$HOME/.colima/default/docker.sock" >> $GITHUB_ENV
60-
# Verify Docker
6171
docker ps
6272
docker --version
63-
# Verify colima
6473
colima status
65-
- uses: actions/setup-python@v4
74+
- uses: actions/setup-python@v5
6675
with:
6776
python-version: ${{ matrix.python }}
6877
cache: 'pip'
@@ -73,18 +82,17 @@ jobs:
7382
pip install --upgrade pip
7483
pip install --upgrade setuptools wheel aws-sam-cli -r https://raw.githubusercontent.com/aws-cloudformation/cloudformation-cli/master/requirements.txt
7584
pip install .
76-
- uses: actions/setup-node@v3
85+
- uses: actions/setup-node@v4
7786
with:
7887
node-version: ${{ matrix.node }}
7988
cache: 'npm'
8089
- name: Install Dependencies Node.js
8190
id: install_nodejs
82-
# Touch needed because of https://github.com/aws/aws-cli/issues/2639
8391
run: |
8492
npm ci --include=optional
8593
find ./node_modules/* -mtime +10950 -exec touch {} \;
8694
npm run build
87-
- uses: actions/cache@v3
95+
- uses: actions/cache@v4
8896
with:
8997
path: ~/.cache/pre-commit/
9098
key: ${{ matrix.os }}-${{ env.pythonLocation }}${{ hashFiles('.pre-commit-config.yaml') }}
@@ -100,9 +108,9 @@ jobs:
100108
bash codecov.sh -f coverage/ts/coverage-final.json -F unittests -n codecov-typescript
101109
- name: Upload Coverage Artifacts
102110
id: upload_coverage
103-
uses: actions/upload-artifact@v3
111+
uses: actions/upload-artifact@v4
104112
with:
105-
name: coverage
113+
name: coverage-${{ matrix.os }}-py${{ matrix.python }}
106114
path: coverage/
107115
- name: Run Integration Tests
108116
id: integration_testing
@@ -140,7 +148,7 @@ jobs:
140148
- name: Upload Debug Artifacts
141149
id: upload_logs
142150
if: failure()
143-
uses: actions/upload-artifact@v3
151+
uses: actions/upload-artifact@v4
144152
with:
145-
name: debug-logs
153+
name: debug-logs-${{ matrix.os }}-py${{ matrix.python }}
146154
path: ${{ env.LOG_PATH }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,5 @@ node_modules/
141141
coverage/
142142

143143
*.iml
144+
# Kiro IDE
145+
.kiro/

.pre-commit-config.yaml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
- id: check-merge-conflict
2828
# - id: check-yaml # have jinja yml templates so skipping this
2929
- repo: https://github.com/pycqa/flake8
30-
rev: "5.0.4"
30+
rev: "7.1.2"
3131
hooks:
3232
- id: flake8
3333
additional_dependencies:
@@ -45,19 +45,18 @@ repos:
4545
- id: python-check-mock-methods
4646
- id: python-no-log-warn
4747
- repo: https://github.com/PyCQA/bandit
48-
rev: 1.7.1
48+
rev: 1.8.3
4949
hooks:
5050
- id: bandit
5151
files: "^python/"
52-
- repo: https://github.com/pre-commit/mirrors-eslint
53-
rev: v8.26.0
52+
- repo: local
5453
hooks:
5554
- id: eslint
56-
args: [--fix]
57-
types: []
58-
files: (.*.js$|.*.ts$)
59-
additional_dependencies:
60-
- eslint@8.21.0
55+
name: eslint
56+
description: Run eslint from local node_modules
57+
entry: npx eslint --fix
58+
language: system
59+
files: \.(js|ts)$
6160
- repo: local
6261
hooks:
6362
- id: pylint-local

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def find_version(*file_paths):
3636
# package_data -> use MANIFEST.in instead
3737
include_package_data=True,
3838
zip_safe=True,
39-
python_requires=">=3.8",
39+
python_requires=">=3.10",
4040
install_requires=[
4141
"cloudformation-cli>=0.1.14",
4242
"zipfile38>=0.0.3,<0.2",

src/interface.ts

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -95,33 +95,40 @@ interface IntegerConstructor {
9595
/**
9696
* Wrapper with additional JSON serialization for bigint type
9797
*/
98-
export const Integer: IntegerConstructor = new Proxy(BigInt as unknown as IntegerConstructor, {
99-
apply(
100-
target: IntegerConstructor,
101-
_thisArg: unknown,
102-
argArray: unknown[]
103-
): integer {
104-
target.prototype.toJSON = function (): number {
105-
return Number(this.valueOf());
106-
};
107-
const isSafeInteger = (value: bigint): boolean => {
108-
if (
109-
value &&
110-
(value < BigInt(Number.MIN_SAFE_INTEGER) ||
111-
value > BigInt(Number.MAX_SAFE_INTEGER))
112-
) {
113-
return false;
98+
export const Integer: IntegerConstructor = new Proxy(
99+
BigInt as unknown as IntegerConstructor,
100+
{
101+
apply(
102+
target: IntegerConstructor,
103+
_thisArg: unknown,
104+
argArray: unknown[]
105+
): integer {
106+
target.prototype.toJSON = function (): number {
107+
return Number(this.valueOf());
108+
};
109+
const isSafeInteger = (value: bigint): boolean => {
110+
if (
111+
value &&
112+
(value < BigInt(Number.MIN_SAFE_INTEGER) ||
113+
value > BigInt(Number.MAX_SAFE_INTEGER))
114+
) {
115+
return false;
116+
}
117+
return true;
118+
};
119+
target.isSafeInteger = isSafeInteger;
120+
const value = target(
121+
...(argArray as [bigint | integer | boolean | number | string])
122+
);
123+
if (value && !isSafeInteger(value)) {
124+
throw new RangeError(
125+
`Value is not a safe integer: ${value.toString()}`
126+
);
114127
}
115-
return true;
116-
};
117-
target.isSafeInteger = isSafeInteger;
118-
const value = target(...(argArray as [bigint | integer | boolean | number | string]));
119-
if (value && !isSafeInteger(value)) {
120-
throw new RangeError(`Value is not a safe integer: ${value.toString()}`);
121-
}
122-
return value;
123-
},
124-
}) as IntegerConstructor;
128+
return value;
129+
},
130+
}
131+
) as IntegerConstructor;
125132

126133
export enum Action {
127134
Create = 'CREATE',

0 commit comments

Comments
 (0)