From 9004debf0d3027d150840fe1db9dfa42d7bd5cbb Mon Sep 17 00:00:00 2001
From: Matthew Smith <masmith@scottlogic.com>
Date: Fri, 10 Feb 2023 17:10:10 +0000
Subject: [PATCH] chore: wip add smoke test for generator-options command
 (#163)

---
 .github/workflows/format.yml     | 28 -----------
 .github/workflows/lint.yml       | 28 -----------
 .github/workflows/release.yml    | 28 -----------
 .github/workflows/smoke.yml      | 80 ++++++++++++++++++++++++++++++++
 .github/workflows/test-forge.yml | 32 -------------
 .github/workflows/test.yml       | 78 -------------------------------
 package.json                     |  1 -
 7 files changed, 80 insertions(+), 195 deletions(-)
 delete mode 100644 .github/workflows/format.yml
 delete mode 100644 .github/workflows/lint.yml
 delete mode 100644 .github/workflows/release.yml
 create mode 100644 .github/workflows/smoke.yml
 delete mode 100644 .github/workflows/test-forge.yml
 delete mode 100644 .github/workflows/test.yml

diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
deleted file mode 100644
index f937947..0000000
--- a/.github/workflows/format.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-name: Format
-
-on:
-  push:
-    branches: [master]
-  pull_request:
-    branches: [master]
-
-jobs:
-  format:
-    name: Format
-    runs-on: ubuntu-latest
-
-    steps:
-      - name: Check out Git repository
-        uses: actions/checkout@v3
-    
-      - name: Use Node.js
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16.x
-          cache: 'npm'
-
-      - name: Install Node.js dependencies
-        run: npm ci
-
-      - name: Code Format Check
-        run: npm run format:check:all
\ No newline at end of file
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
deleted file mode 100644
index 02b8bda..0000000
--- a/.github/workflows/lint.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-name: Lint
-
-on:
-  push:
-    branches: [master]
-  pull_request:
-    branches: [master]
-
-jobs:
-  lint:
-    name: Lint
-    runs-on: ubuntu-latest 
-
-    steps:
-      - name: Check out Git repository
-        uses: actions/checkout@v3
-      
-      - name: Use Node.js
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16.x
-          cache: 'npm'
-
-      - name: Install Node.js dependencies
-        run: npm ci
-
-      - name: Code Lint Check
-        run: npm run lint:check:all
\ No newline at end of file
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
deleted file mode 100644
index 26a3b9d..0000000
--- a/.github/workflows/release.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-name: Release
-
-on:
-  push:
-    branches: [master]
-
-jobs:
-  release:
-    name: Release
-    runs-on: ubuntu-latest
-    steps:
-      - name: Check out Git repository
-        uses: actions/checkout@v3
-  
-      - name: Use Node.js
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16.x
-          cache: 'npm'
-
-      - name: Install Node.js dependencies
-        run: npm ci
-  
-      - name: Release
-        env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
-        run: npx semantic-release
\ No newline at end of file
diff --git a/.github/workflows/smoke.yml b/.github/workflows/smoke.yml
new file mode 100644
index 0000000..bdd8723
--- /dev/null
+++ b/.github/workflows/smoke.yml
@@ -0,0 +1,80 @@
+name: Smoke Tests
+
+on:
+  push:
+    branches:
+      - "**"
+  pull_request:
+    branches:
+      - "**"
+
+jobs:
+  smoke-tests:
+    name: Smoke Tests
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: Check out Git repository
+        uses: actions/checkout@v3
+  
+      - name: Use Node.js
+        uses: actions/setup-node@v3
+        with:
+          node-version: 16.x
+          cache: 'npm'
+
+      - name: Install Node.js dependencies
+        run: |
+          npm install
+
+      - name: Check out the openapi-forge-javascript generator
+        uses: actions/checkout@v3
+        with: 
+          repository: ScottLogic/openapi-forge-javascript
+          path: openapi-forge-javascript
+
+      - name: Install openapi-forge-javascript dependencies
+        run: |
+          cd openapi-forge-javascript
+          npm install
+
+      - name: Return to the main folder
+        run: |
+          cd ..
+
+      - name: Make script executable
+        run: |
+          chmod +x ./src/index.js
+
+      # - name: Test Generator Options Command
+      #   run: |
+      #     echo "generator-options=$(./src/index.js generator-options openapi-forge-javascript)" >> $GITHUB_OUTPUT
+      #   id: generator_options
+      - id: generator_options
+        name: Test Generator Options Command
+        run: |
+          echo "generator-options<<EOF" >> $GITHUB_OUTPUT
+          echo "$(./src/index.js generator-options openapi-forge-javascript)" >> $GITHUB_OUTPUT
+          echo "EOF" >> $GITHUB_OUTPUT
+
+      - name: Print
+        run: echo "steps.generator_options.outputs.generator-options"
+
+      - name: Check Output of Generator Options
+        if: contains("something with moduleFormat", "moduleFormat") # steps.generator_options.outputs.generator-options
+        run: |
+          echo "hooray!" 
+        if: "!contains("something with moduleFormat", "moduleFormat")"  # steps.generator_options.outputs.generator-options
+        run: |
+          echo "oh noes!"
+
+      # - name: Check Output of Generator Options
+      #   run: |
+      #     echo "Checking the output for moduleFormat"
+      #     if grep -q "moduleFormat" <${{join(steps.generator_options.outputs.*, '\n')}}; then
+      #       echo "Output includes moduleFormat"
+      #     else
+      #       echo "ERROR: Output does not include moduleFormat"
+      #       echo "Full Output: ${{join(steps.generator_options.outputs.*, '\n')}}"
+      #       exit 1
+      #     fi
diff --git a/.github/workflows/test-forge.yml b/.github/workflows/test-forge.yml
deleted file mode 100644
index 2783e6f..0000000
--- a/.github/workflows/test-forge.yml
+++ /dev/null
@@ -1,32 +0,0 @@
-name: Test Forge
-
-on:
-  push:
-    branches:
-      - "**"
-  pull_request:
-    branches:
-      - "**"
-
-jobs:
-  test-forge:
-    name: Test Forge
-    runs-on: ubuntu-latest
-
-    steps:
-      - name: Check out Git repository
-        uses: actions/checkout@v3
-  
-      - name: Use Node.js
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16.x
-          cache: 'npm'
-
-      - name: Install Node.js dependencies
-        run: |
-          npm install
-
-      - name: Test Forge
-        run: |
-          npm test
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
deleted file mode 100644
index 8c40908..0000000
--- a/.github/workflows/test.yml
+++ /dev/null
@@ -1,78 +0,0 @@
-name: Test
-
-on:
-  push:
-    branches: [master]
-  pull_request:
-    branches: [master]
-
-jobs:
-  test-generators:
-    name: Test
-    runs-on: windows-latest 
-
-    steps:
-      - name: Use Node.js
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16.x
-
-        # Must change shell because this workflow uses the windows-latest image 
-      - name: Set npm shell
-        run: npm config set script-shell "C:\\Program Files\\Git\\bin\\bash.exe"
-
-      - name: Check out openapi-forge repository
-        uses: actions/checkout@v3
-        with: 
-          path: openapi-forge
-
-      - name: Install openapi-forge dependencies globally
-        run: |
-          cd openapi-forge
-          npm install
-          npm install --global
-
-      - name: Check out the openapi-forge-javascript generator
-        uses: actions/checkout@v3
-        with: 
-          repository: ScottLogic/openapi-forge-javascript
-          path: openapi-forge-javascript
-
-      - name: Install openapi-forge-javascript dependencies
-        run: |
-          cd openapi-forge-javascript
-          npm install
-
-      - name: Check out the openapi-forge-csharp generator
-        uses: actions/checkout@v3
-        with: 
-          repository: ScottLogic/openapi-forge-csharp
-          path: openapi-forge-csharp
-
-      - name: Install openapi-forge-csharp dependencies
-        run: |
-          cd openapi-forge-csharp
-          npm install
-
-      - name: Check out the openapi-forge-typescript generator
-        uses: actions/checkout@v3
-        with: 
-          repository: ScottLogic/openapi-forge-typescript
-          path: openapi-forge-typescript
-
-      - name: Install openapi-forge-typescript dependencies
-        run: |
-          cd openapi-forge-typescript
-          npm install
-
-      - name: Test generators
-        run: |
-          cd openapi-forge
-          openapi-forge test-generators --format json --generators openapi-forge-javascript openapi-forge-typescript openapi-forge-csharp > test-results.json
-        continue-on-error: true
-
-      - name: Upload test results
-        uses: actions/upload-artifact@v3
-        with:
-          name: test-results
-          path: openapi-forge/test-results.json
\ No newline at end of file
diff --git a/package.json b/package.json
index e01050c..83c57d1 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,6 @@
   "description": "Effortlessly create OpenAPI clients from the fiery furnace of our forge",
   "main": "src/generate.js",
   "scripts": {
-    "prepare": "husky install",
     "test:generators": "openapi-forge test-generators",
     "test": "jest",
     "format:check:all": "prettier --check .",