Skip to content

CI

CI #351

Workflow file for this run

name: CI
on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
branches:
- main
jobs:
test:
name: Test
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install
working-directory: airbyte-local-cli-nodejs
run: npm ci --no-audit --no-fund
- name: Build
working-directory: airbyte-local-cli-nodejs
run: npm run build
- name: Lint
working-directory: airbyte-local-cli-nodejs
run: npm run lint
- name: Test
working-directory: airbyte-local-cli-nodejs
env:
FAROS_API_KEY: ${{ secrets.FAROS_API_KEY }}
run: npm run test -- --coverage --color
- name: Package
working-directory: airbyte-local-cli-nodejs
run: npm run pkg -- --target linuxstatic
- name: Build Shellspec image
working-directory: test
run: |
docker build . -t 'farosai/shellspec:kcov'
# Run shellspec tests againgst airbyte-local.sh
- name: Run ShellSpec tests
run: |
docker run --rm \
-v "$PWD/test:/src" \
-v "$PWD/airbyte-local.sh:/airbyte-local.sh" \
farosai/shellspec:kcov
- name: Install ShellSpec
run: |
curl -fsSL https://git.io/shellspec | sh -s 0.28.1 --yes
# Run shellspec tests againgst airbyte-local nodejs
- name: Run ShellSpec tests
working-directory: airbyte-local-cli-nodejs
env:
FAROS_API_KEY: ${{ secrets.FAROS_API_KEY }}
run: |
cp ./out/pkg/airbyte-local ./test/exec/airbyte-local
cp -rf ./test/resources ./test/exec/resources
shellspec --chdir ./test/exec
- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
tag:
name: Tag
needs: [test]
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.ref == 'refs/heads/main'
outputs:
createdTag: ${{ steps.create-tag.outputs.tag }}
steps:
- name: Check out
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Create tag
id: create-tag
uses: salsify/action-detect-and-tag-new-version@v2
with:
version-command: cat airbyte-local-cli-nodejs/package.json | jq -r '.version'
build:
name: Build
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
platform: [x64, arm64]
exclude:
- os: windows-latest
platform: arm64
runs-on: ${{ matrix.os }}
timeout-minutes: 15
needs: [tag]
# Only run if the tag was created
if: needs.tag.outputs.createdTag != null
permissions:
contents: write
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 20.x
- name: Install
working-directory: airbyte-local-cli-nodejs
shell: bash
run: |
npm ci --no-audit --no-fund
npm run version
- name: Package for Platform
working-directory: airbyte-local-cli-nodejs
shell: bash
run: |
if [ "${{ runner.os }}" == 'Windows' ]; then
TARGET="win-${{ matrix.platform }}"
BINARY_NAME=$TARGET
else
TARGET="${{ runner.os == 'macOS' && 'macos' || 'linuxstatic' }}-${{ matrix.platform }}"
BINARY_NAME="${{ runner.os == 'macOS' && 'macos' || 'linux' }}-${{ matrix.platform }}"
fi
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
npm run pkg -- --target $TARGET
- name: Compress Linux/MacOS binaries
working-directory: airbyte-local-cli-nodejs/out/pkg
if: runner.os != 'Windows'
run: |
zip airbyte-local-${BINARY_NAME}.zip airbyte-local
- name: Compress Windows binaries
working-directory: airbyte-local-cli-nodejs/out/pkg
if: runner.os == 'Windows'
run: |
Compress-Archive -Path airbyte-local.exe -DestinationPath airbyte-local-win-x64.zip
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: release_${{ env.BINARY_NAME }}
path: airbyte-local-cli-nodejs/out/pkg/airbyte-local-${{ env.BINARY_NAME }}.zip
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [tag, build]
steps:
- name: Download All Artifacts
uses: actions/download-artifact@v4
with:
path: airbyte-local-cli-nodejs/out/pkg
- name: List Downloaded Binaries
run: |
ls -R airbyte-local-cli-nodejs/out/pkg
- name: Release
uses: softprops/action-gh-release@v2
with:
files: |
airbyte-local-cli-nodejs/out/pkg/release_linux-x64/airbyte-local-linux-x64.zip
airbyte-local-cli-nodejs/out/pkg/release_linux-arm64/airbyte-local-linux-arm64.zip
airbyte-local-cli-nodejs/out/pkg/release_macos-x64/airbyte-local-macos-x64.zip
airbyte-local-cli-nodejs/out/pkg/release_macos-arm64/airbyte-local-macos-arm64.zip
airbyte-local-cli-nodejs/out/pkg/release_win-x64/airbyte-local-win-x64.zip
tag_name: ${{ needs.tag.outputs.createdTag }}