on:
  workflow_dispatch:
  pull_request:
    branches:
      - main

jobs:
  test-compose-action:
    runs-on: ubuntu-latest
    name: test compose action
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 16
      - run: npm install
      - uses: ./
        with:
          compose-file: "./docker/docker-compose.yml"
          services: |
            helloworld2
            helloworld3
      - uses: ./
        with:
          compose-file: "./docker/docker-compose.yml"
          down-flags: "--volumes"
      - uses: ./
        with:
          compose-file: "./docker/docker-compose.yml"
          compose-flags: "--profile profile-1"
          down-flags: "--volumes"
      - uses: ./
        with:
          compose-file: "./docker/docker-compose-with-env.yml"
        env:
          IMAGE_NAME: hello-world
      - uses: ./
        with:
          compose-file: |
            ./docker/docker-compose.yml
            ./docker/docker-compose.ci.yml
          services: |
            helloworld2
            helloworld4
  lint:
    runs-on: ubuntu-latest
    name: lint test
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: 16

      - run: npm install

      - name: eslint
        run: npm run lint

      - name: prettier
        run: npm run check-format
