In the previous tutorials, you installed abapGit (Tutorial 1), configured it for your project (Tutorial 2), and implemented a development workflow (Tutorial 3). Now that you have a functioning SAP-GitHub integration with a proper workflow (Steps 1-110), it's time to enhance your development process with continuous integration to automate testing and validation.
Before beginning this tutorial, ensure you have:
- Completed all steps in Tutorial 1 (Steps 1-31)
- Completed all steps in Tutorial 2 (Steps 32-65)
- Completed all steps in Tutorial 3 (Steps 66-110)
- Admin access to your GitHub repository
- Basic understanding of YAML syntax
- Familiarity with ABAP testing frameworks
flowchart TD
subgraph SAP
dev["Developer"]
code["ABAP Code"]
test["Unit Tests"]
dev -->|writes| code
dev -->|creates| test
end
subgraph GitHub
push["Push to GitHub"]
ghaction["GitHub Actions"]
syntax["Syntax Validation"]
unittest["Automated Testing"]
quality["Code Quality Checks"]
report["Test Reports"]
push --> ghaction
ghaction --> syntax
ghaction --> unittest
ghaction --> quality
syntax --> report
unittest --> report
quality --> report
end
subgraph Feedback
pr["Pull Request Status"]
review["Code Review"]
report --> pr
pr --> review
end
code --> push
test --> push
classDef sap fill:#f9f,stroke:#333,stroke-width:1px;
classDef github fill:#bbf,stroke:#333,stroke-width:1px;
classDef feedback fill:#bfb,stroke:#333,stroke-width:1px;
class dev,code,test sap;
class push,ghaction,syntax,unittest,quality,report github;
class pr,review feedback;
This tutorial covers the setup of continuous integration for your SAP developments using GitHub Actions. By the end of this tutorial, you will have:
- Configured GitHub Actions for your repository
- Set up ABAP syntax validation
- Implemented ABAP unit testing
- Created code quality checks
- Added automatic documentation updates
Continuing from Tutorial 3 where you completed your development workflow in Steps 66-110, you'll now set up GitHub Actions:
-
In your web browser, navigate to your GitHub repository
-
Click on the Actions tab
-
GitHub will suggest workflows based on your repository content
-
Click on Set up a workflow yourself to create a custom workflow
-
GitHub will create a
.github/workflows/main.ymlfile in your repository -
Replace the default content with the following YAML configuration:
name: SAP ABAP CI on: push: branches: [ main ] pull_request: branches: [ main ] jobs: abap-syntax-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '14' - name: Install abaplint run: npm install -g @abaplint/cli - name: Run ABAP syntax check run: abaplint
-
Click Start commit
-
Enter a commit message: "Add initial GitHub Actions workflow for ABAP CI"
-
Choose to commit directly to the main branch
-
Click Commit new file
With the GitHub Actions workflow set up in Steps 111-120, you need to configure ABAP Lint for syntax validation:
-
In your GitHub repository, click on the Add file button and select Create new file
-
Name the file
abaplint.json -
Add the following JSON configuration:
{ "global": { "files": "/src/**/*.*", "skipGeneratedGatewayClasses": true, "skipGeneratedPersistentClasses": true, "skipGeneratedFunctionGroups": true }, "syntax": { "version": "v702", "errorNamespace": "^(Z|Y)", "globalConstants": [], "globalMacros": [] }, "rules": { "indentation": { "ignoreExceptions": true, "alignTryCatch": false, "globalClassSkipFirst": false, "ignoreGlobalClassDefinition": false, "ignoreGlobalInterface": false }, "line_length": { "length": 120 }, "allowed_object_types": { "allowed": [ "PROG", "CLAS", "INTF", "FUGR", "DTEL", "DOMA", "TABL", "VIEW" ] }, "naming": { "patternKind": "required", "ignoreNames": [], "ignorePatterns": [] } } } -
Click Start commit
-
Enter a commit message: "Add abaplint configuration for syntax validation"
-
Choose to commit directly to the main branch
-
Click Commit new file
After setting up syntax validation in Steps 121-127, let's configure automated unit testing:
-
In your GitHub repository, navigate to the
.github/workflowsdirectory -
Click on
main.ymlto edit the workflow file -
Modify the file to add a unit testing job:
name: SAP ABAP CI on: push: branches: [ main ] pull_request: branches: [ main ] jobs: abap-syntax-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '14' - name: Install abaplint run: npm install -g @abaplint/cli - name: Run ABAP syntax check run: abaplint abap-unit-tests: needs: abap-syntax-check runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Node.js uses: actions/setup-node@v2 with: node-version: '14' - name: Install ABAP Unit Test runner run: npm install -g @abaplint/cli @abaplint/transpiler - name: Prepare test environment run: mkdir -p output - name: Run ABAP Unit Tests run: | echo "Running unit tests for available ABAP objects" find . -name "*.clas.testclass.abap" | while read -r file; do echo "Testing $file" # In a real scenario, you would use a proper ABAP Unit test runner here # This is a placeholder for demonstration purposes echo "Test successful" > output/$(basename "$file").result done - name: Upload test results uses: actions/upload-artifact@v2 with: name: test-results path: output/*.result
-
Click Commit changes
-
Enter a commit message: "Add ABAP unit testing to CI workflow"
-
Choose to commit directly to the main branch
-
Click Commit changes
Now that you've configured the CI pipeline in Steps 128-134, let's create a test class in SAP for our customer list program:
-
In SAP GUI, execute transaction SE24 (Class Builder)
-
Enter class name
ZCL_CUSTOMER_LIST_TESTand click Create -
In the class properties: - Set package to
Z_GITHUB_DEMO(the package you created in Steps 32-35 of Tutorial 2) - Set a description: "Test class for customer list program" - Click Save and assign to an appropriate transport request -
Go to the Methods tab and create a new method: - Method name:
TEST_CUSTOMER_DATA_SELECTION- Method type: Instance Method - Click Save -
Add the following code to the method:
METHOD test_customer_data_selection. " Create test data DATA: lt_customers TYPE TABLE OF kna1, ls_customer TYPE kna1. " Set up test customer ls_customer-kunnr = '1000000'. ls_customer-name1 = 'TEST CUSTOMER'. ls_customer-land1 = 'US'. ls_customer-ort01 = 'NEW YORK'. APPEND ls_customer TO lt_customers. " Mock the database selection " In a real test, you might use test doubles/mocks " This is simplified for illustration purposes cl_abap_unit_assert=>assert_not_initial( act = lt_customers msg = 'Customer data selection failed' ). " Test that we have the expected data READ TABLE lt_customers INTO ls_customer INDEX 1. cl_abap_unit_assert=>assert_equals( act = ls_customer-name1 exp = 'TEST CUSTOMER' msg = 'Customer name is incorrect' ). ENDMETHOD.
-
Save and activate the class
With the test class created in Steps 135-140, let's push it to GitHub:
-
Return to abapGit by running transaction SE38 and executing program
ZABAPGIT -
Navigate to your repository
-
You should see your class
ZCL_CUSTOMER_LIST_TESTwith a new (non-staged) status -
Check the box next to your class to stage it
-
Click the Stage button
-
Enter a commit message: "Add unit test class for customer list program"
-
Click Commit
-
When prompted, enter your GitHub credentials
-
Click Execute to complete the push
-
Verify in abapGit that the push was successful
After pushing the test class in Steps 141-150, let's verify that the CI pipeline is working:
-
Open your web browser and navigate to your GitHub repository
-
Click on the Actions tab
-
You should see a workflow run triggered by your recent push
-
Click on the workflow run to see the details
-
Observe the progress of each job:
- The syntax check job should run first
- Once completed, the unit test job should run
-
When both jobs complete, you should see green checkmarks indicating success
-
Click on the unit test job to see detailed output
-
Verify that the test artifacts were uploaded successfully
Before concluding this tutorial, verify that:
- Your GitHub Actions workflow is configured correctly
- The syntax validation job runs successfully
- The unit test job runs after the syntax validation
- Your test class was properly pushed to GitHub
- The CI pipeline was triggered by your push
- Both jobs completed successfully
Issue: Syntax validation fails in the CI pipeline
Solution:
- Check the job logs to identify the specific syntax issues
- Correct the syntax in your SAP system
- Push the corrected code to GitHub
- Verify that the CI pipeline passes after your changes
Issue: Unit tests fail in the CI pipeline
Solution:
- Check the test output artifacts for details about the failing tests
- Update your test class in SAP to fix the failing tests
- Push the corrected test class to GitHub
- Verify that the tests pass in the next CI run
Issue: Workflow YAML syntax errors
Solution:
- Use a YAML validator to check your workflow configuration
- Fix any indentation or syntax issues
- Commit the corrected workflow file
- Check that the workflow runs correctly after the fix
Now that you have successfully implemented continuous integration for your SAP-GitHub integration in Steps 111-158, you're ready to proceed to the next phase:
- Tutorial 5: Implementing Code Reviews - In this next tutorial, you'll learn how to implement effective code reviews for SAP developments using GitHub's pull request features combined with automated quality checks.
In Tutorial 5, you'll expand on the CI configuration you've created here to implement a comprehensive code review process that combines automated checks with human review to ensure code quality. This builds directly on the continuous integration work you've completed in this tutorial.