Code Monkey home page Code Monkey logo

Comments (8)

foosinn avatar foosinn commented on July 22, 2024

Hey,

sorry for the late reply. Can you add some logging on your own? Especialy around the chanes that came with the last Version:

3e82ec0#diff-9a2cdc7907fa6a4bfc94da76b035c282R52

Namely repoBranch, commitBranch, before and after.

Im unsure why this is causing issues.

Thanks!

from drone-tree-config.

bartimaeus avatar bartimaeus commented on July 22, 2024

Thanks for the response @foosinn! I tried running everything locally with the latest build and it appears to build the master branch; however, now it is always building the same sub-project and referencing the same commit every time.

I am new to go, but tried looking through the source code and found that drone-tree-config calls the github api asking for the difference between two commits.

Below is an example output I get from pushing a commit on a master branch: GitHub Webhook -> GitHub Diff -> drone-tree-config log.

GitHub Webhook

{
  ...
  "compare": 
  "https://github.com/org/monorepo/compare/2974355b58a8...1132d604c2e0",
    "commits": [
      {
        "id": "fb8c7401619411a8e2ab5faffccd2ba6ce8a0e88",
        "tree_id": "f1271afa1d56c36f6936959f8f78ea1d755041bd",
        "distinct": false,
        "message": "Ignore local .env.production file",
        "timestamp": "2020-03-09T11:40:30-06:00",
        "url": "https://github.com/org/monorepo/commit/fb8c7401619411a8e2ab5faffccd2ba6ce8a0e88",
        "author": {
          "name": "Eric Shelley",
          "email": "[email protected]",
          "username": "bartimaeus"
        },
        "committer": {
          "name": "Eric Shelley",
          "email": "[email protected]",
          "username": "bartimaeus"
        },
        "added": [],
        "removed": [],
        "modified": [
        "packages/manage/.gitignore"
        ]
      },
      {
        "id": "1132d604c2e054125389943105c3a333aa6b9426",
        "tree_id": "60745b1959163b42237d0fca04247a71b76b6fc8",
        "distinct": true,
        "message": "Merge branch 'develop'\n\n* develop:\n  Ignore local .env.production file",
        "timestamp": "2020-03-09T11:40:57-06:00",
        "url": "https://github.com/org/monorepo/commit/1132d604c2e054125389943105c3a333aa6b9426",
        "author": {
          "name": "Eric Shelley",
          "email": "[email protected]",
          "username": "bartimaeus"
        },
        "committer": {
          "name": "Eric Shelley",
          "email": "[email protected]",
          "username": "bartimaeus"
        },
        "added": [],
        "removed": [],
        "modified": [
          "packages/manage/.gitignore"
        ]
      }
    ],
    ...
}

GitHub Diff API Response

{
    ...
    "files": [
        {
            "sha": "2538b99d3538b702c705cc6b9b24f99cd7dd070a",
            "filename": "packages/manage/.gitignore",
            "status": "modified",
            "additions": 1,
            "deletions": 0,
            "changes": 1,
            ...
            "patch": "@@ -16,6 +16,7 @@\n .env.local\n .env.development.local\n .env.test.local\n+.env.production\n .env.production.local\n \n npm-debug.log*"
        }
    ]
}

drone-tree-config log

drone_tree_config            | time="2020-03-09T19:10:39Z" level=debug msg="3a511a34-c67b-4603-a766-33b73e89eb60 changed files: \n  packages/app/src/referrals/referrals/DetailsDrawer.js"

No matter what I push to the master branch, it appears to always try to build packages/app because it thinks I changed DetailsDrawer.js. I was hoping that a fresh github oauth app and running drone-tree-config locally would produce a different result, but it did not.

Could there be a git cache somewhere?

from drone-tree-config.

foosinn avatar foosinn commented on July 22, 2024

Sorry for the long delay. I was out of office last week.

Is the default branch configured in drone the master branch?

from drone-tree-config.

bartimaeus avatar bartimaeus commented on July 22, 2024

No worries @foosinn. I appreciate your help. I have two pipelines in the file. The first one works fine and is triggered on the develop branch. The second pipeline is triggered on the master branch

Here is my .drone.yml

---
kind: pipeline
name: manage [staging]

steps:
  - name: restore npm cache
    image: drillster/drone-volume-cache
    volumes:
      - name: cache
        path: /staging-manage
    settings:
      restore: true
      mount:
        - ./packages/manage/node_modules

  - name: test & build
    image: node
    environment:
      GENERATE_SOURCEMAP: true
      REACT_APP_API_ENDPOINT:
        from_secret: staging_main_api_url
    commands:
      - cd packages/manage
      - yarn install
      - yarn test
      - yarn build

  - name: sync
    image: mesosphere/aws-cli
    environment:
      AWS_ACCESS_KEY_ID:
        from_secret: staging_aws_access_key_id
      AWS_SECRET_ACCESS_KEY:
        from_secret: staging_aws_secret_access_key
      S3_BUCKET:
        from_secret: staging_manage_bucket_name
      DISTRIBUTION_ID:
        from_secret: staging_manage_cloudfront_distribution_id
    commands:
      - aws s3 sync packages/manage/build s3://$S3_BUCKET --cache-control "max-age=14400,public"
      - aws s3 cp s3://$S3_BUCKET/service-worker.js s3://$S3_BUCKET/service-worker.js --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type application/javascript
      - aws s3 cp s3://$S3_BUCKET/index.html s3://$S3_BUCKET/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html
      - aws cloudfront create-invalidation --distribution-id $${DISTRIBUTION_ID} --paths '/*'

  - name: rebuild npm cache
    image: drillster/drone-volume-cache
    volumes:
      - name: cache
        path: /staging-manage
    settings:
      rebuild: true
      mount:
        - ./packages/manage/node_modules

  - name: slack
    image: plugins/slack
    settings:
      webhook:
        from_secret: slack_webhook
      channel: status
      template: >
        {{#success build.status}}
          *success* <{{build.link}}|manage ({{build.branch}})> by {{build.author}}
        {{else}}
          *failure* <{{build.link}}|manage ({{build.branch}})> by {{build.author}}
        {{/success}}
    when:
      status: [success, failure]

volumes:
  - name: cache
    host:
      path: /mnt/efs/drone/cache

trigger:
  branch:
    - develop

---
kind: pipeline
name: manage [production]

steps:
  - name: restore npm cache
    image: drillster/drone-volume-cache
    volumes:
      - name: cache
        path: /production-manage
    settings:
      restore: true
      mount:
        - ./packages/manage/node_modules

  - name: test & build
    image: node
    environment:
      GENERATE_SOURCEMAP: true
      REACT_APP_API_ENDPOINT:
        from_secret: production_main_api_url
    commands:
      - cd packages/manage
      - yarn install
      - yarn test
      - yarn build
  - name: sync
    image: mesosphere/aws-cli
    environment:
      AWS_ACCESS_KEY_ID:
        from_secret: production_aws_access_key_id
      AWS_SECRET_ACCESS_KEY:
        from_secret: production_aws_secret_access_key
      S3_BUCKET:
        from_secret: production_manage_bucket_name
      DISTRIBUTION_ID:
        from_secret: production_manage_cloudfront_distribution_id
    commands:
      - aws s3 sync packages/manage/build s3://$S3_BUCKET --cache-control "max-age=14400,public"
      - aws s3 cp s3://$S3_BUCKET/service-worker.js s3://$S3_BUCKET/service-worker.js --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type application/javascript
      - aws s3 cp s3://$S3_BUCKET/index.html s3://$S3_BUCKET/index.html --metadata-directive REPLACE --cache-control max-age=0,no-cache,no-store,must-revalidate --content-type text/html
      - aws cloudfront create-invalidation --distribution-id $${DISTRIBUTION_ID} --paths '/*'

  - name: rebuild npm cache
    image: drillster/drone-volume-cache
    volumes:
      - name: cache
        path: /production-manage
    settings:
      rebuild: true
      mount:
        - ./packages/manage/node_modules

  - name: slack
    image: plugins/slack
    settings:
      webhook:
        from_secret: slack_webhook
      channel: status
      template: >
        {{#success build.status}}
          *success* <{{build.link}}|manage ({{build.branch}})> by {{build.author}}
        {{else}}
          *failure* <{{build.link}}|manage ({{build.branch}})> by {{build.author}}
        {{/success}}
    when:
      status: [success, failure]

volumes:
  - name: cache
    host:
      path: /mnt/efs/drone/cache

trigger:
  branch:
    - master

from drone-tree-config.

foosinn avatar foosinn commented on July 22, 2024

Hey, can you please validate with the latest release? (v0.3.6)

from drone-tree-config.

bartimaeus avatar bartimaeus commented on July 22, 2024

Hi @foosinn, I just tried with v0.3.6. Same error. It recognized the commit I pushed, but started processing an old commit in a different directory. I wish I knew go better.

from drone-tree-config.

bartimaeus avatar bartimaeus commented on July 22, 2024

@foosinn, I believe I found the issue. My repos are setup so that develop is the main branch and automatically deploys to staging. The master branch is the branch that will automatically deploy to production.

Because my repo's default branch is set to develop, this line will always set before to develop when commits are made to the master branch.

from drone-tree-config.

foosinn avatar foosinn commented on July 22, 2024

Can you verify using v0.4.1?

from drone-tree-config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.