From 009eec9475b7cb9edbcc8ca287ea268fc611063b Mon Sep 17 00:00:00 2001 From: andres-portainer <91705312+andres-portainer@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:22:31 -0300 Subject: [PATCH] fix(compose): avoid the need to pass the file to remove the stack BE-11057 (#12065) Co-authored-by: andres-portainer Co-authored-by: Yajith Dayarathna --- .github/workflows/test.yaml | 31 +++++++++++++------ Makefile | 3 ++ .../internal/composeplugin/composeplugin.go | 6 ++-- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ff5a59a56..d08b1dd1a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -28,15 +28,22 @@ jobs: if: github.event.pull_request.draft == false steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - name: 'checkout the current branch' + uses: actions/checkout@v4.1.1 + with: + ref: ${{ github.event.inputs.branch }} + + - name: 'set up node.js' + uses: actions/setup-node@v4.0.1 with: node-version: ${{ env.NODE_VERSION }} cache: 'yarn' + - run: yarn --frozen-lockfile - name: Run tests run: make test-client ARGS="--maxWorkers=2 --minWorkers=1" + test-server: strategy: matrix: @@ -49,15 +56,21 @@ jobs: if: github.event.pull_request.draft == false steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - name: 'checkout the current branch' + uses: actions/checkout@v4.1.1 + with: + ref: ${{ github.event.inputs.branch }} + + - name: 'set up golang' + uses: actions/setup-go@v5.0.0 with: go-version: ${{ env.GO_VERSION }} - - name: Install docker-compose - run: | - sudo apt-get update - sudo apt-get install docker-compose + - name: 'install dependencies' + run: make test-deps PLATFORM=linux ARCH=amd64 - - name: Run tests + - name: 'update $PATH' + run: echo "$(pwd)/dist" >> $GITHUB_PATH + + - name: 'run tests' run: make test-server diff --git a/Makefile b/Makefile index 254705e31..1ef82293b 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,9 @@ clean: ## Remove all build and download artifacts .PHONY: test test-client test-server test: test-server test-client ## Run all tests +test-deps: init-dist + ./build/download_docker_compose_binary.sh $(PLATFORM) $(ARCH) $(shell jq -r '.dockerCompose' < "./binary-version.json") + test-client: ## Run client tests yarn test $(ARGS) diff --git a/pkg/libstack/compose/internal/composeplugin/composeplugin.go b/pkg/libstack/compose/internal/composeplugin/composeplugin.go index 5516da640..c22009cb4 100644 --- a/pkg/libstack/compose/internal/composeplugin/composeplugin.go +++ b/pkg/libstack/compose/internal/composeplugin/composeplugin.go @@ -57,7 +57,7 @@ func (wrapper *PluginWrapper) Deploy(ctx context.Context, filePaths []string, op // Down stop and remove containers func (wrapper *PluginWrapper) Remove(ctx context.Context, projectName string, filePaths []string, options libstack.Options) error { - output, err := wrapper.command(newDownCommand(projectName, filePaths), options) + output, err := wrapper.command(newDownCommand(projectName), options) if len(output) != 0 { if err != nil { return err @@ -217,8 +217,8 @@ func newUpCommand(filePaths []string, options upOptions) composeCommand { return newCommand(args, filePaths) } -func newDownCommand(projectName string, filePaths []string) composeCommand { - cmd := newCommand([]string{"down", "--remove-orphans"}, filePaths) +func newDownCommand(projectName string) composeCommand { + cmd := newCommand([]string{"down", "--remove-orphans"}, nil) cmd.WithProjectName(projectName) return cmd