very_good_workflows icon indicating copy to clipboard operation
very_good_workflows copied to clipboard

feat: workflow for Bitbucket Pipelines (migration help)

Open starfoxcom opened this issue 2 years ago โ€ข 1 comments

Description Hello, I really don't know if this is the right place to make this question, but after a full day of research trying to find help of some sort about this issue that I have, I don't know were else I can go to ask about it.

In my current job we are using the very good core template, which has a lot of tools and rules to follow, which we are not using/following properly (the project was already started before I arrived to work on it). So I convinced them that its the right choice to restart the project and follow the rules and the recomendations stablished by the template. But now I understand that the main issue was that, since we're using Bitbucket for our repo hosting, it was not possible to use the very good core template to its fullest, so I started to migrate the workflow the best I could to be used on with Bitbucket Pipelines.

So far I made possible to get 4 out of the 5 steps:

  1. โœ… Install Dependencies
  2. โœ… Format
  3. โœ… Analyze
  4. โœ… Run tests
  5. โŒ Check Code Coverage

The only one that I'm missing still is the Check Code Coverage one, but since it's a github action by itself, I researched on how to run the internal js scripts inside the action, but I haven't been able to do it right.

My question: It's possible to run the action in the console with the node command to run the action steps? if its possible, which files does the console needs to know in the directory to make it work? since it seems that the files depends from some others, just that I haven't figure it out yet, this is not my forte :V.

This is only to know if its gonna be possible to make the full migration from GitHub Actions to Bitbucket Pipelines, but if at the end this is not something that the team developing this have in mind that can be possible, then I guess I'll leave it like that.

Hope to hear something about soon, have a great day!

PT: since the issue template only available was only the bug one, the issue has the bug tag, even if its not one, I was not able to notice/fix it before publishing the issue, my bad.

starfoxcom avatar May 24 '22 02:05 starfoxcom

UPDATE So I've been researching and learning about the dist/index.js file, which is the one used on the action mainly, and I've been able to run it with the node command inside the command line in the Pipeline. This is the final code that I came up with:

image: cirrusci/flutter

pipelines:
  pull-requests:
    feature/*:
      - step:
          name: ๐Ÿฆ Flutter Pipeline
          script:
          - |
            echo "๐Ÿ“ฆ Install Dependencies"
            export PATH="$PATH":"$HOME/.pub-cache/bin"
            flutter pub global activate very_good_cli
            very_good --analytics false
            very_good packages get
          - |
            echo "โœจ Check Formatting"
            flutter format --set-exit-if-changed lib test
          - |
            echo "๐Ÿ•ต๏ธ Analyze"
            flutter analyze lib test
          - |
            echo "๐Ÿงช Run Tests"
            very_good test --optimization --coverage --test-randomize-ordering-seed random
          - |
            echo "๐Ÿ“Š Check Code Coverage"
            git clone https://github.com/VeryGoodOpenSource/very_good_coverage.git
            sudo apt update
            sudo apt install -y nodejs
            sudo apt install -y npm
            node -v
            npm -v
            INPUT_PATH="./coverage/lcov.info" INPUT_MIN_COVERAGE=100 node ./very_good_coverage/dist/index.js
      - step:
          name: Deploy to test
          deployment: test
          trigger: manual  # Uncomment to make this a manual deployment.
          script:
            - echo "Deploying to test environment"

I'm sure that it has plenty of improvement to it, but this is the first successful run of the Pipeline in the Bitbucket Repo. In case that you're in need of this, remember that it has to be on the root directory of the repo you want to use it, and it has to be in the bitbucket-pipelines.yml file.

Feel free to comment about it or improve it as you like. Also, I think it would be a nice idea to have this file set up with the create of the very good core template, for those who use it on Bitbucket at least.

Have a nice day!

starfoxcom avatar May 24 '22 11:05 starfoxcom