Skip to content

Commit

Permalink
fix(flows): enforce compilation (#1881)
Browse files Browse the repository at this point in the history
## Describe your changes

- Enforce flow compilation in the CI 
We have forgotten multiple times to compile this file before merging to
master, and also it has been overwrote by mistake.
Use a CI check (example of failing here
https://github.com/NangoHQ/nango/actions/runs/8358118696/job/22878717461?pr=1881)

- Add missing packages for the scripts
  • Loading branch information
bodinsamuel committed Mar 20, 2024
1 parent 2ef8f40 commit 96d1fbb
Show file tree
Hide file tree
Showing 10 changed files with 117 additions and 177 deletions.
35 changes: 17 additions & 18 deletions .github/workflows/integration-flows.yaml
Expand Up @@ -7,7 +7,6 @@ on:
- staging/**
pull_request:


concurrency:
group: flows-compile--${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand All @@ -27,23 +26,23 @@ jobs:

- name: Install nango CLI
run: |
# Build, install CLI and verify it can run
npm install
npm run build -w @nangohq/node -w @nangohq/shared -w nango
npm install -g ./packages/cli
NANGO_CLI_UPGRADE_MODE=ignore nango version --debug
# Build, install CLI and verify it can run
npm install
npm run build -w @nangohq/node -w @nangohq/shared -w nango
npm install -g ./packages/cli
NANGO_CLI_UPGRADE_MODE=ignore nango version --debug
- name: Compile with Nango
run: |
set -e
cd integration-templates
for dir in */; do
if [[ "$dir" != "." && "$dir" != "integration-templates/" ]]; then
cd "$dir"
mkdir -p nango-integrations
find . -maxdepth 1 ! -name '.' ! -name 'nango-integrations' -exec mv -t nango-integrations {} +
cd nango-integrations
NANGO_CLI_UPGRADE_MODE=ignore nango compile
cd ../../
fi
done
set -e
cd integration-templates
for dir in */; do
if [[ "$dir" != "." && "$dir" != "integration-templates/" ]]; then
cd "$dir"
mkdir -p nango-integrations
find . -maxdepth 1 ! -name '.' ! -name 'nango-integrations' -exec mv -t nango-integrations {} +
cd nango-integrations
NANGO_CLI_UPGRADE_MODE=ignore nango compile
cd ../../
fi
done
20 changes: 9 additions & 11 deletions .github/workflows/push-container.yaml
Expand Up @@ -23,21 +23,19 @@ jobs:
- uses: docker/setup-buildx-action@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
node-version: '18.x'
- uses: docker/login-action@v3
if: env.CAN_PUSH == 'true'
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push container
env:
PUSH: ${{ (env.CAN_PUSH == 'true') && '--push' || '' }}
PUSH: ${{ (env.CAN_PUSH == 'true') && '--push' || '' }}
run: |
echo "Building: '${{ inputs.package }}'"
echo "Tags: ${{ inputs.tags }}"
npm i
npm run ${{ inputs.run-cmd }}
node scripts/flows.js
docker buildx build -f packages/${{ inputs.package }}/Dockerfile --platform linux/amd64 ${{ inputs.tags }} . --no-cache ${{ env.PUSH }}
echo "Building: '${{ inputs.package }}'"
echo "Tags: ${{ inputs.tags }}"
npm i
npm run ${{ inputs.run-cmd }}
docker buildx build -f packages/${{ inputs.package }}/Dockerfile --platform linux/amd64 ${{ inputs.tags }} . --no-cache ${{ env.PUSH }}
17 changes: 16 additions & 1 deletion .github/workflows/tests.yaml
Expand Up @@ -7,7 +7,6 @@ on:
- staging/**
pull_request:


concurrency:
group: tests-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
Expand All @@ -21,10 +20,26 @@ jobs:

steps:
- uses: actions/checkout@v3
with:
fetch-depth: '0'

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm run build:hosted
- run: npm run test:unit
- run: npm run test:integration

- name: Make sure flows.yaml is compiled
run: |
node ./scripts/flows.js
REPO_DIRTY=$(git status --short)
if [[ ! -z "$REPO_DIRTY" ]]; then
git diff
echo ""
echo -e "\r⛔️ flows.yaml hasn't been compiled, please run:"
echo -e "node ./scripts/flows.js"
exit 1
fi
2 changes: 2 additions & 0 deletions .husky/pre-commit
@@ -1,4 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

node ./scripts/flows.js
git add ./packages/shared/flows.yaml
npx lint-staged --allow-empty
29 changes: 17 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -66,6 +66,7 @@
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"husky": "^8.0.3",
"js-yaml": "4.1.0",
"lint-staged": "15.2.2",
"onchange": "^7.1.0",
"prettier": "3.2.5",
Expand Down

0 comments on commit 96d1fbb

Please sign in to comment.