• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

common-workflow-language / cwlviewer / #1761

28 Feb 2025 02:09AM CUT coverage: 70.306%. Remained the same
#1761

Pull #682

github

web-flow
Bump actions/cache from 4.2.0 to 4.2.2

Bumps [actions/cache](https://github.com/actions/cache) from 4.2.0 to 4.2.2.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4.2.0...v4.2.2)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #682: Bump actions/cache from 4.2.0 to 4.2.2

1700 of 2418 relevant lines covered (70.31%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/org/commonwl/view/cwl/CWLToolRunner.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.commonwl.view.cwl;
21

22
import java.io.IOException;
23
import java.nio.file.Path;
24
import java.util.Date;
25
import org.apache.jena.query.QueryException;
26
import org.commonwl.view.git.GitDetails;
27
import org.commonwl.view.git.GitLicenseException;
28
import org.commonwl.view.git.GitSemaphore;
29
import org.commonwl.view.git.GitService;
30
import org.commonwl.view.researchobject.ROBundleFactory;
31
import org.commonwl.view.util.FileUtils;
32
import org.commonwl.view.workflow.QueuedWorkflow;
33
import org.commonwl.view.workflow.QueuedWorkflowRepository;
34
import org.commonwl.view.workflow.Workflow;
35
import org.commonwl.view.workflow.WorkflowRepository;
36
import org.eclipse.jgit.api.Git;
37
import org.eclipse.jgit.api.errors.TransportException;
38
import org.eclipse.jgit.errors.MissingObjectException;
39
import org.slf4j.Logger;
40
import org.slf4j.LoggerFactory;
41
import org.springframework.beans.factory.annotation.Autowired;
42
import org.springframework.scheduling.annotation.Async;
43
import org.springframework.scheduling.annotation.EnableAsync;
44
import org.springframework.stereotype.Component;
45

46
/** Replace existing workflow with the one given by cwltool */
47
@Component
48
@EnableAsync
49
public class CWLToolRunner {
50

51
  private final Logger logger = LoggerFactory.getLogger(this.getClass());
×
52

53
  private final WorkflowRepository workflowRepository;
54
  private final QueuedWorkflowRepository queuedWorkflowRepository;
55
  private final CWLService cwlService;
56
  private final ROBundleFactory roBundleFactory;
57
  private final String cwlToolVersion;
58
  private final GitSemaphore gitSemaphore;
59
  private final GitService gitService;
60

61
  @Autowired
62
  public CWLToolRunner(
63
      WorkflowRepository workflowRepository,
64
      QueuedWorkflowRepository queuedWorkflowRepository,
65
      CWLService cwlService,
66
      CWLTool cwlTool,
67
      ROBundleFactory roBundleFactory,
68
      GitSemaphore gitSemaphore,
69
      GitService gitService) {
×
70
    this.workflowRepository = workflowRepository;
×
71
    this.queuedWorkflowRepository = queuedWorkflowRepository;
×
72
    this.cwlService = cwlService;
×
73
    this.cwlToolVersion = cwlTool.getVersion();
×
74
    this.roBundleFactory = roBundleFactory;
×
75
    this.gitSemaphore = gitSemaphore;
×
76
    this.gitService = gitService;
×
77
  }
×
78

79
  @Async
80
  public void createWorkflowFromQueued(QueuedWorkflow queuedWorkflow)
81
      throws IOException, InterruptedException {
82

83
    Workflow tempWorkflow = queuedWorkflow.getTempRepresentation();
×
84
    GitDetails gitInfo = tempWorkflow.getRetrievedFrom();
×
85
    final String repoUrl = gitInfo.getRepoUrl();
×
86
    // Parse using cwltool and replace in database
87
    Git repo = null;
×
88
    try {
89
      boolean safeToAccess = gitSemaphore.acquire(repoUrl);
×
90
      repo = gitService.getRepository(gitInfo, safeToAccess);
×
91
      Path localPath = repo.getRepository().getWorkTree().toPath();
×
92
      Path workflowFile = localPath.resolve(gitInfo.getPath()).normalize().toAbsolutePath();
×
93
      Workflow newWorkflow =
×
94
          cwlService.parseWorkflowWithCwltool(tempWorkflow, workflowFile, localPath);
×
95

96
      // Success
97
      newWorkflow.setRetrievedFrom(tempWorkflow.getRetrievedFrom());
×
98
      newWorkflow.setRetrievedOn(new Date());
×
99
      newWorkflow.setLastCommit(tempWorkflow.getLastCommit());
×
100
      newWorkflow.setCwltoolVersion(cwlToolVersion);
×
101

102
      workflowRepository.save(newWorkflow);
×
103

104
      // Generate RO bundle
105
      roBundleFactory.createWorkflowRO(newWorkflow);
×
106

107
      // Mark success on queue
108
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.SUCCESS);
×
109

110
    } catch (QueryException ex) {
×
111
      logger.error("Jena query exception for workflow " + queuedWorkflow.getId(), ex);
×
112
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
113
      queuedWorkflow.setMessage("An error occurred when executing a query on the SPARQL store");
×
114
      FileUtils.deleteGitRepository(repo);
×
115
    } catch (CWLValidationException | GitLicenseException ex) {
×
116
      String message = ex.getMessage();
×
117
      logger.error(
×
118
          "Workflow " + queuedWorkflow.getId() + " from " + gitInfo.toSummary() + " : " + message,
×
119
          ex);
120
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
121
      queuedWorkflow.setMessage(message);
×
122
      FileUtils.deleteGitRepository(repo);
×
123
    } catch (TransportException ex) {
×
124
      String message = ex.getMessage();
×
125
      logger.error(
×
126
          "Workflow retrieval error while processing "
127
              + queuedWorkflow.getId()
×
128
              + " from "
129
              + gitInfo.toSummary()
×
130
              + " : "
131
              + message,
132
          ex);
133
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
134
      if (message.contains(
×
135
          "Authentication is required but no CredentialsProvider has been registered")) {
136
        queuedWorkflow.setMessage(
×
137
            "Unable to retrieve the Git repository: it may be private, misnamed, or removed. "
138
                + message);
139
      } else {
140
        queuedWorkflow.setMessage(message);
×
141
      }
142
      FileUtils.deleteGitRepository(repo);
×
143
    } catch (MissingObjectException ex) {
×
144
      String message = ex.getMessage();
×
145
      logger.error(
×
146
          "Workflow retrieval error while processing "
147
              + queuedWorkflow.getId()
×
148
              + " from "
149
              + gitInfo.toSummary()
×
150
              + " : "
151
              + message,
152
          ex);
153
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
154
      queuedWorkflow.setMessage("Unable to retrieve a needed Git object: " + message);
×
155
      FileUtils.deleteGitRepository(repo);
×
156
    } catch (Exception ex) {
×
157
      logger.error(
×
158
          "Unexpected error processing workflow "
159
              + queuedWorkflow.getId()
×
160
              + " from "
161
              + gitInfo.toSummary()
×
162
              + " : "
163
              + ex.getMessage(),
×
164
          ex);
165
      queuedWorkflow.setCwltoolStatus(CWLToolStatus.ERROR);
×
166
      queuedWorkflow.setMessage(
×
167
          "Whoops! Cwltool ran successfully, but an unexpected "
168
              + "error occurred in CWLViewer!\n"
169
              + ex.getMessage()
×
170
              + "\nHelp us by reporting it at https://github.com/common-workflow-language/cwlviewer/issues/new/choose\n");
171
      FileUtils.deleteGitRepository(repo);
×
172
    } finally {
173
      gitSemaphore.release(repoUrl);
×
174
      FileUtils.deleteTemporaryGitRepository(repo);
×
175
      queuedWorkflowRepository.save(queuedWorkflow);
×
176
    }
177
  }
×
178
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc