Skip to content

Commit

Permalink
ci: reuse preparation steps
Browse files Browse the repository at this point in the history
  • Loading branch information
limwa committed Jul 17, 2024
1 parent 5259b67 commit a72c130
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 3,313 deletions.
48 changes: 48 additions & 0 deletions .github/actions/prepare-pulumi-project/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: "Prepare Pulumi project"
description: "Installs dependencies and clones the project"
inputs:
node-version:
description: "Node version"
required: false
default: "22"
crd2pulumi-version:
description: "crd2pulumi version"
required: false
default: "v1.4.0"
yq-version:
description: "yq version"
required: false
default: "v4.40.3"
runs:
using: composite
steps:

- name: Install yq
shell: sh
run: sudo curl -L https://github.com/mikefarah/yq/releases/download/${{ inputs.yq-version }}/yq_linux_amd64 -o /usr/bin/yq && sudo chmod +x /usr/bin/yq

- name: Install crd2pulumi
shell: sh
run: |
mkdir -p ./bin/crd2pulumi
cd ./bin/crd2pulumi
echo "crd2pulumi" > files.txt
curl -L https://github.com/pulumi/crd2pulumi/releases/download/${{ inputs.crd2pulumi-version }}/crd2pulumi-${{ inputs.crd2pulumi-version }}-linux-amd64.tar.gz | tar -T files.txt -xvz
sudo mv crd2pulumi /usr/bin/crd2pulumi
sudo chmod +x /usr/bin/crd2pulumi
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
package_json_file: services/pulumi/package.json

- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
cache: "pnpm"
cache-dependency-path: services/pulumi/pnpm-lock.yaml

- name: Sync CRDs
shell: sh
run: ./services/pulumi/sync-crds.sh
44 changes: 4 additions & 40 deletions .github/workflows/pulumi-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,21 @@ on:
branches: [ "main" ]
paths: [ "services/pulumi/**" ]

defaults:
run:
working-directory: services/pulumi

jobs:
format:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
package_json_file: services/pulumi/package.json
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
cache-dependency-path: services/pulumi/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install
- uses: ./.github/actions/prepare-pulumi-project
- name: Run prettier
working-directory: services/pulumi/niployments
run: pnpm run prettier

lint:
name: ESLint
runs-on: ubuntu-latest
steps:
- name: Install yq
working-directory: ${{ github.workspace }}
run: sudo curl -L https://github.com/mikefarah/yq/releases/download/v4.40.3/yq_linux_amd64 -o /usr/bin/yq && sudo chmod +x /usr/bin/yq
- name: Install crd2pulumi
working-directory: ${{ github.workspace }}
run: |
mkdir -p ./bin/crd2pulumi
cd ./bin/crd2pulumi
echo "crd2pulumi" > files.txt
curl -L https://github.com/pulumi/crd2pulumi/releases/download/v1.4.0/crd2pulumi-v1.4.0-linux-amd64.tar.gz | tar -T files.txt -xvz
sudo mv crd2pulumi /usr/bin/crd2pulumi
sudo chmod +x /usr/bin/crd2pulumi
- uses: actions/checkout@v4
- name: Sync CRDs
run: ./sync-crds.sh
- uses: pnpm/action-setup@v4
with:
package_json_file: services/pulumi/package.json
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
cache-dependency-path: services/pulumi/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install
- uses: ./.github/actions/prepare-pulumi-project
- name: Run ESLint
working-directory: services/pulumi/niployments
run: pnpm run lint
5 changes: 1 addition & 4 deletions services/pulumi/niployments/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Pnpm files
/node_modules/
/bin/
package.json
pnpm-lock.yaml

# Automatically generated files
/crds/

# Assets
/assets/
2 changes: 1 addition & 1 deletion services/pulumi/niployments/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export default tseslint.config(
ignores: ["eslint.config.mjs"],
},
{
ignores: ["node_modules", "crds", "assets"],
ignores: ["node_modules", "bin", "assets"],
},
);
Loading

0 comments on commit a72c130

Please sign in to comment.