supercharge / mongodb-github-action

Use MongoDB in GitHub Actions
MIT License
222 stars 46 forks source link

mongoimport command not found #41

Closed wifidabba closed 1 year ago

wifidabba commented 1 year ago

Hi pals, the following is my GitHub action, the problem is MongoDB is not getting recognised or having some issue wile running the jobs.

Even mongoimport is not recognised because mongo is not getting detected. Give me the following error

mongoimport: command not found

name: API Continous Integration

# Controls when the action will run. Triggers the workflow on push or pull request
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  continous_integration:
    runs-on: ubuntu-latest
    strategy:
      #We can run on multiple versions of dependencies with the help of 'matrix'
      matrix:
        node-version: [18.x]
        mongodb-version: ["6.0"]

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      #Checkout project code
      - name: Git Checkout
        uses: actions/checkout@v3

      #Install Node.js
      - name: Install NodeJs ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node-version }}

      #MongoDB server
      - name: Start MongoDB ${{ matrix.mongodb-version }}
        uses: supercharge/mongodb-github-action@1.8.0
        with:
          mongodb-version: ${{ matrix.mongodb-version }}
          mongodb-username: ${{ secrets.DB_MONGODB_USERNAME }}
          mongodb-password: ${{ secrets.DB_MONGODB_PASSWORD }}
          mongodb-db: ${{ secrets.DB_MONGODB_DATABASE }}
          mongodb-port: ${{ secrets.DB_MONGODB_PORT }}

      #Load mongodb collections
      - name: Add data to countries Collection
        run: mongoimport --host=127.0.0.1 --db=${{ secrets.DB_MONGODB_DATABASE }} --port=${{ secrets.DB_MONGODB_PORT }} --username=${{ secrets.DB_MONGODB_USERNAME }} --password=${{ secrets.DB_MONGODB_PASSWORD }} --collection=countries --file=src/database/raw/countries.json

      #Clean install package and any packages that it depends on
      - name: Install dependencies
        run: npm ci

      #Run the integration tests
      - name: Run tests
        run: npm test
wifidabba commented 1 year ago

If I use ubuntu-20.04 I am able to make it work. Also I know that mongoimport is removed in Ubuntu 22.x, but tried multiple other options but not working with ubuntu-latest

marcuspoehls commented 1 year ago

@wifidabba Hey Karam, the Ubuntu 22.04 runners for GitHub Actions don’t have MongoDB installed by default. The 20.04 runners have MongoDB installed.

Please have a look at this related issue: https://github.com/supercharge/mongodb-github-action/issues/39