github.com/bilus/oya@v0.0.3-0.20190301162104-da4acbd394c6/features/imports.feature (about)

     1  Feature: Running tasks
     2  
     3  Background:
     4     Given I'm in project dir
     5  
     6  Scenario: Import tasks from installed packs
     7    Given file ./Oyafile containing
     8      """
     9      Project: project
    10  
    11      Require:
    12        github.com/test/foo: v0.0.1
    13  
    14      Import:
    15        foo: github.com/test/foo
    16      """
    17    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
    18      """
    19      all: |
    20        foo=4
    21        if [ $$foo -ge 3 ]; then
    22          touch OK
    23        fi
    24        echo "Done"
    25      """
    26    When I run "oya run foo.all"
    27    Then the command succeeds
    28    And the command outputs to stdout
    29    """
    30    Done
    31  
    32    """
    33    And file ./OK exists
    34  
    35  Scenario: Import task using pack values
    36    Given file ./Oyafile containing
    37      """
    38      Project: project
    39  
    40      Require:
    41        github.com/test/foo: v0.0.1
    42  
    43      Import:
    44        foo: github.com/test/foo
    45      """
    46    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
    47      """
    48      Values:
    49        foo: xxx
    50      all: |
    51        bar="$foo"
    52        echo $$bar
    53      """
    54    When I run "oya run foo.all"
    55    Then the command succeeds
    56    And the command outputs to stdout
    57    """
    58    xxx
    59  
    60    """
    61  
    62  Scenario: Import task using BasePath
    63    Given file ./Oyafile containing
    64      """
    65      Project: project
    66  
    67      Require:
    68        github.com/test/foo: v0.0.1
    69  
    70      Import:
    71        foo: github.com/test/foo
    72      """
    73    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
    74      """
    75      Values:
    76        foo: xxx
    77      all: |
    78        bar=$$(basename $BasePath)
    79        echo $$bar
    80      """
    81    When I run "oya run foo.all"
    82    Then the command succeeds
    83    And the command outputs to stdout
    84    """
    85    foo@v0.0.1
    86  
    87    """
    88  
    89  Scenario: Access pack values
    90    Given file ./Oyafile containing
    91      """
    92      Project: project
    93  
    94      Require:
    95        github.com/test/foo: v0.0.1
    96  
    97      Import:
    98        foo: github.com/test/foo
    99      all: |
   100        echo $foo.bar
   101      """
   102    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   103      """
   104      Values:
   105        bar: xxx
   106      """
   107    When I run "oya run all"
   108    Then the command succeeds
   109    And the command outputs to stdout
   110    """
   111    xxx
   112  
   113    """
   114  
   115  Scenario: Access current project values
   116    Given file ./Oyafile containing
   117      """
   118      Project: main
   119      Values:
   120        foo: main
   121      """
   122    And file ./project1/Oyafile containing
   123      """
   124      Values:
   125        foo: project1
   126      """
   127    And file ./project2/Oyafile containing
   128      """
   129      Import:
   130        main: /
   131        p1: /project1
   132      Values:
   133        foo: project2
   134      all: |
   135        echo $main.foo
   136        echo $p1.foo
   137        echo $foo
   138      """
   139    When I run "oya run --recurse all"
   140    Then the command succeeds
   141    And the command outputs to stdout
   142    """
   143    main
   144    project1
   145    project2
   146  
   147    """
   148  
   149  Scenario: Pack values can be set from project Oyafile prefixed with pack alias
   150    Given file ./Oyafile containing
   151      """
   152      Project: project
   153  
   154      Require:
   155        github.com/test/foo: v0.0.1
   156  
   157      Import:
   158        foo: github.com/test/foo
   159  
   160      Values:
   161        foo:
   162          fruit: banana
   163      """
   164    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   165      """
   166      all: |
   167        echo $fruit
   168      """
   169    When I run "oya run foo.all"
   170    Then the command succeeds
   171    And the command outputs to stdout
   172    """
   173    banana
   174  
   175    """
   176  
   177  Scenario: Pack values are overriden in main Oyafile
   178    Given file ./Oyafile containing
   179      """
   180      Project: project
   181  
   182      Require:
   183        github.com/test/foo: v0.0.1
   184  
   185      Import:
   186        foo: github.com/test/foo
   187  
   188      Values:
   189        foo:
   190          wege: broccoli
   191      """
   192    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   193      """
   194      Values:
   195        fruit: banana
   196        wege: carrot
   197  
   198      all: |
   199        echo $fruit
   200        echo $wege
   201      """
   202    When I run "oya run foo.all"
   203    Then the command succeeds
   204    And the command outputs to stdout
   205    """
   206    banana
   207    broccoli
   208  
   209    """
   210  
   211  # Regression test for #24
   212  Scenario: Import tasks in a subdir Oyafile
   213    Given file ./Oyafile containing
   214      """
   215      Project: project
   216  
   217      Require:
   218        github.com/test/foo: v0.0.1
   219  
   220      """
   221    And file ./subdir/Oyafile containing
   222      """
   223      Import:
   224        foo: github.com/test/foo
   225      """
   226    And file ./.oya/packs/github.com/test/foo@v0.0.1/Oyafile containing
   227      """
   228      all: |
   229        echo "all"
   230      """
   231    And I'm in the ./subdir dir
   232    When I run "oya run --recurse foo.all"
   233    Then the command succeeds
   234    And the command outputs to stdout
   235    """
   236    all
   237  
   238    """
   239  
   240  Scenario: Import tasks from a subdirectory
   241    Given file ./Oyafile containing
   242      """
   243      Project: main
   244      """
   245    And file ./project1/Oyafile containing
   246      """
   247      Values:
   248        foo: project1
   249  
   250      echo: |
   251        echo "project1"
   252      """
   253    And file ./project2/Oyafile containing
   254      """
   255      Import:
   256        project1: /project1
   257      """
   258    And I'm in the ./project2 dir
   259    When I run "oya run project1.echo"
   260    Then the command succeeds
   261    And the command outputs to stdout
   262    """
   263    project1
   264  
   265    """