Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Flaconi/platform @Flaconi/ci
43 changes: 43 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
version: 2
registries:
npm-npmjs:
type: npm-registry
url: https://registry.npmjs.org
replaces-base: true
token: ${{ secrets.NPM_TOKEN }}
github-flaconi-ci:
type: git
url: https://github.com
username: x-access-token
password: ${{secrets.REPO_READ_TOKEN}}
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "08:00"
timezone: Europe/Berlin
open-pull-requests-limit: 10
registries:
- npm-npmjs
ignore:
- dependency-name: "node-fetch"
versions: ["3.x"]
groups:
production:
dependency-type: production
update-types: [minor, patch]
production-major:
dependency-type: production
update-types: [major]
development:
dependency-type: development
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
day: monday
time: "08:00"
timezone: Europe/Berlin
registries:
- github-flaconi-ci
32 changes: 32 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.

- [ ] Test A
- [ ] Test B

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
34 changes: 34 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
template: |
## Changes

$CHANGES
name-template: '$RESOLVED_VERSION 🌈'
tag-template: '$RESOLVED_VERSION'
categories:
- title: '🚀 Features'
labels:
- feature
- enhancement
- title: '🐛 Bug Fixes'
labels:
- fix
- bugfix
- bug
- title: '🧰 Maintenance'
labels:
- chore
- dependencies
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
major:
labels:
- 'major'
minor:
labels:
- 'minor'
patch:
labels:
- 'patch'
default: patch
268 changes: 268 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
name: Continuous Integration

on:
push:
branches: [ main, master, feature/*, release/*, hotfix/* ]
pull_request:
branches: [ main, master ]
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Smart change detection and validation
detect-changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
has-code-changes: ${{ steps.changes.outputs.code }}
has-dependency-changes: ${{ steps.changes.outputs.dependencies }}
has-workflow-changes: ${{ steps.changes.outputs.workflows }}
should-run-tests: ${{ steps.decision.outputs.run-tests }}
should-publish: ${{ steps.decision.outputs.publish }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Detect file changes
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
code:
- 'index.js'
- 'getAwsOptions.js'
- 'resolveStackOutput.js'
- 'test/**'
dependencies:
- 'package.json'
- 'package-lock.json'
workflows:
- '.github/workflows/**'

- name: Make decisions
id: decision
run: |
# Always run tests for PR or if code/deps changed
if [[ "${{ github.event_name }}" == "pull_request" ]] || \
[[ "${{ steps.changes.outputs.code }}" == "true" ]] || \
[[ "${{ steps.changes.outputs.dependencies }}" == "true" ]]; then
echo "run-tests=true" >> $GITHUB_OUTPUT
else
echo "run-tests=false" >> $GITHUB_OUTPUT
fi

# Only publish on main/master push with code changes
if [[ "${{ github.event_name }}" == "push" ]] && \
[[ "${{ github.ref }}" == "refs/heads/main" || "${{ github.ref }}" == "refs/heads/master" ]] && \
[[ "${{ steps.changes.outputs.code }}" == "true" ]]; then
echo "publish=true" >> $GITHUB_OUTPUT
else
echo "publish=false" >> $GITHUB_OUTPUT
fi

# Comprehensive testing matrix
test:
name: Test (Node.js ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.should-run-tests == 'true'

strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run linting
run: |
if npm run lint --if-present; then
echo "Linting passed"
else
echo "No linting script found, skipping"
fi

- name: Run type checking
run: |
if npm run type-check --if-present; then
echo "Type checking passed"
else
echo "No type checking script found, skipping"
fi

- name: Run tests with coverage
run: npm run test:coverage

- name: Upload coverage to Codecov
if: matrix.node-version == '18.x'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false

- name: Run basic integration test
run: npm run test:basic

# Security and quality checks
security:
name: Security & Quality
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.should-run-tests == 'true'

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Security audit
run: |
echo "Running security audit..."
npm audit --audit-level high

- name: Check for outdated dependencies
run: |
echo "Checking for outdated dependencies..."
npm outdated || echo "Some dependencies may be outdated"

- name: License check
run: |
echo "Validating license compliance..."
if command -v license-checker &> /dev/null; then
npx license-checker --summary
else
echo "License checker not available, skipping"
fi

# Build validation
build:
name: Build Validation
runs-on: ubuntu-latest
needs: detect-changes
if: needs.detect-changes.outputs.should-run-tests == 'true'

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Validate package.json
run: |
echo "Validating package.json structure..."
node -e "
const pkg = require('./package.json');
const required = ['name', 'version', 'description', 'main', 'author', 'license'];
const missing = required.filter(field => !pkg[field]);
if (missing.length > 0) {
console.error('Missing required fields:', missing.join(', '));
process.exit(1);
}
console.log('Package.json validation passed');
"

- name: Test package installation
run: |
echo "Testing package installation..."
npm pack
PKG_FILE=$(ls *.tgz)
npm install -g "$PKG_FILE"
echo "Package installs successfully"

# Pre-publish validation
pre-publish:
name: Pre-publish Validation
runs-on: ubuntu-latest
needs: [test, security, build]
if: needs.detect-changes.outputs.should-publish == 'true'

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Final test run
run: npm test

- name: Check if version exists on NPM
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
echo "Current version: $CURRENT_VERSION"

if npm view @flaconi/serverless-s3-sync@$CURRENT_VERSION version &>/dev/null; then
echo "Version $CURRENT_VERSION already exists on NPM"
echo "Please bump the version before publishing"
exit 1
else
echo "Version $CURRENT_VERSION is available for publishing"
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Dry run publish
run: npm publish --dry-run --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to NPM
run: |
echo "Publishing to NPM..."
npm publish --access public
echo "Successfully published to NPM"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# Status reporting
ci-success:
name: CI Success
runs-on: ubuntu-latest
needs: [detect-changes, test, security, build]
if: always() && (needs.detect-changes.outputs.should-run-tests == 'false' || (needs.test.result == 'success' && needs.security.result == 'success' && needs.build.result == 'success'))

steps:
- name: Report success
run: |
echo "All CI checks passed successfully!"
echo "Changes detected: ${{ needs.detect-changes.outputs.has-code-changes }}"
echo "Tests required: ${{ needs.detect-changes.outputs.should-run-tests }}"
echo "Publish ready: ${{ needs.detect-changes.outputs.should-publish }}"
Loading