Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path Filtering Orb Doesn't Detect Changes #102

Open
gnikolov5 opened this issue Feb 21, 2024 · 2 comments
Open

Path Filtering Orb Doesn't Detect Changes #102

gnikolov5 opened this issue Feb 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@gnikolov5
Copy link

gnikolov5 commented Feb 21, 2024

Orb version:

pathfiltering orb version 1.0.0

What happened:

Hello,

I am experiencing issue with the path-filtering orb.

The default parameters for triggering a workflow are set to false in the continue_config, and in the config they are set to true, however the changes within the directories are not detected and the parameter doesn’t change its value to true.

I’ve tried correcting the mapping paths based on the exact directory that the code is located in the circleci istance that is being used during deploy but without success.

Weird part is I have another repo with 99% similar configuration that is working as expected.

I have created a separate branch from the one that I am working on so from feature/KI-10 to feature/KI-10-pipe-test just to make sure that it will do the base-revision based on the changes between the KI-10 and KI-10-pipe-test branch.

I also testeed the base-revision to branch withiut the "/" symbol as suggested here: https://discuss.circleci.com/t/path-filtering-orb-not-triggering-workflows/50517

I've tried with a lot of different configurations, however the simpliest one is this:

config.yml:

version: 2.1

setup: true

orbs:
  path-filtering: circleci/[email protected]

workflows:
  setup-workflow:
    jobs:
      - path-filtering/filter:
          base-revision: feature/KI-10-pipe-test
          config-path: .circleci/continue_config.yml
          mapping: |
            cloud-dev/01-route-53/.* trigger-cloud-dev-dir-01-route53 true

continue_config.yml:

version: 2.1

deploy_branch: &deploy_branch
  filters:
    branches:
      only: feature/KI-10

orbs:
  terraform: circleci/[email protected]

executors:
  base:
    docker:
      - image: ptccorp/image:latest
#-----------
# PARAMETERS
#-----------

###########################################
###Trigger Workflow Parameters Cloud-Dev###
###########################################
parameters:
  trigger-cloud-dev-dir-01-route53:
    type: boolean
    default: false

#########################################
###Directory Path Parameters Cloud-Dev###
#########################################

  cloud-dev-dir-path-01-route53:
    type: string
    default: /home/circleci/project/cloud-dev/01_route53


#-----------
# WORKFLOWS
#-----------
#########################
###Cloud-Dev Workflows###
#########################

workflows:
  cloud-dev-deploy-01-route53:
    when: 
      or: 
        - << pipeline.parameters.trigger-cloud-dev-dir-01-route53 >>
    jobs:
      - terraform/init:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
      - terraform/plan:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
          persist-workspace: true
          out: tf_plan_01_route_53
          requires:
            -  terraform/init
      - deploy-approval:
          <<: *deploy_branch
          name: 'Approval Gate AWS'
          type: approval
          requires:
            - terraform/plan

Example from one of the many tries:
https://app.circleci.com/pipelines/bitbucket/kadanza/kadanza-saas-infra/2706/workflows/04a0e9a8-14aa-4096-a319-51f7292f4bdf/jobs/2430

Expected behavior:

The goal is to trigger the workflows if changes are detected within the specified directories.

Additional Information:

Any advices are highly welcome, as I am struggling to find a solution for a couple of days now, thank you!

@gnikolov5 gnikolov5 added the bug Something isn't working label Feb 21, 2024
@gnikolov5
Copy link
Author

Just did some more testing, it looks like the issue is related to the mapping itself.
I tried with the following mapping:

cloud-dev/.* trigger-cloud-dev-dir-01-route53 true

And it worked, however I want to trigger the workflow only when there are changes within cloud-dev/01_route53/.*

Any ideas?

@gnikolov5
Copy link
Author

I think I found a solution

config.yml

version: 2.1

setup: true

orbs:
  path-filtering: circleci/[email protected]

workflows:
  setup-workflow:
    jobs:
      - path-filtering/filter:
          base-revision: pipe-test
          mapping: |
            cloud-dev/01_route53/.* trigger-cloud-dev-dir-01-route53 true .circleci/continue_config_cloud_dev.yml
            dev/01_route53/.* trigger-dev-dir-01-route53 true .circleci/continue_config_dev.yml

continue_config_cloud_dev.yml:

version: 2.1

deploy_branch: &deploy_branch
  filters:
    branches:
      only: feature/KI-10

orbs:
  terraform: circleci/[email protected]

executors:
  base:
    docker:
      - image: ptccorp/tf-aws:latest
#-----------
# PARAMETERS
#-----------

###########################################
###Trigger Workflow Parameters Cloud-Dev###
###########################################
parameters:
  trigger-cloud-dev-dir-01-route53:
    type: boolean
    default: false

#########################################
###Directory Path Parameters Cloud-Dev###
#########################################

  cloud-dev-dir-path-01-route53:
    type: string
    default: /root/project/cloud-dev/01_route53

#-----------
# WORKFLOWS
#-----------
#########################
###Cloud-Dev Workflows###
#########################

workflows:
  cloud-dev-deploy-01-route53:
    when: 
      or: 
        - << pipeline.parameters.trigger-cloud-dev-dir-01-route53 >>
    jobs:
      - terraform/init:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
      - terraform/plan:
          <<: *deploy_branch
          checkout: true
          path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
          persist-workspace: true
          out: tf_plan_01_route53
          requires:
            -  terraform/init
      - deploy-approval:
          <<: *deploy_branch
          name: 'Approval Gate AWS'
          type: approval
          requires:
            - terraform/plan
      # - terraform/apply:
      #     <<: *deploy_branch
      #     checkout: true
      #     path: << pipeline.parameters.cloud-dev-dir-path-01-route53 >>
      #     attach-workspace: true
      #     plan: 'tf_plan_01_route53'
      #     requires:
      #     - Approval Gate AWS

It turns out also the default directory of the instance was changed from /home/circleci to /root I have no idea why as I was using the same image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant