Skip to content

Commit

Permalink
[WIP] test workflow_run
Browse files Browse the repository at this point in the history
  • Loading branch information
WonyoungChoi committed Sep 24, 2021
1 parent 5b19d3d commit 780e5fe
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/check-symbol.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Check Symbols

on:
workflow_run:
workflows: ["Build"]
types: [completed]

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: flutter-tizen/tizen_allowlist
token: ${{ secrets.MY_PAT }}
path: tizen_allowlist
- uses: TizenAPI/tizenfx-build-actions/download-workflow-artifacts@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
path: artifacts
- run: |
ls -al artifacts
ls -al tizen_allowlist
ls -al ci/docker/tizen/tools/
82 changes: 82 additions & 0 deletions ci/docker/tizen/tools/check-symbol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/usr/bin/env python
# Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import subprocess
import sys


class Symbol:
def __init__(self, addr, type, name):
self.addr = addr
self.type = type
self.name = name

def __str__(self):
return '{} {} {}'.format(self.addr, self.type, self.name)

@staticmethod
def parse(line):
return Symbol(line[:8].strip(), line[9], line[11:].strip())


def check_symbol(sofile, allowlist):
if not os.access(sofile, os.R_OK):
raise Exception('{} is not readable'.format(sofile))
if not os.access(allowlist, os.R_OK):
raise Exception('{} is not readable'.format(allowlist))

try:
symbols_raw = subprocess.check_output(
['nm', '-gDC', sofile]).decode('utf-8').splitlines()
symbols = [Symbol.parse(line) for line in symbols_raw]
except subprocess.CalledProcessError as e:
raise Exception('nm failed: {}'.format(e))

with open(allowlist, 'r') as f:
allowlist = [line.strip() for line in f.readlines()]

not_allowed = []
for symbol in symbols:
if symbol.addr:
continue
if symbol.name.startswith('FlutterEngine'):
continue
if symbol.name in allowlist:
continue
not_allowed.append(symbol)

if not_allowed:
print('Symbols not allowed ({}):'.format(sofile))
for symbol in not_allowed:
print(symbol)
return False

return True


def main():
import optparse
parser = optparse.OptionParser(usage='%prog [options] [sofile ..]')
parser.add_option('--allowlist', dest='allowlist',
help='Path to the allowlist file')
(options, args) = parser.parse_args()

if not options.allowlist:
print('--allowlist is required')
return 1
if not args:
print('sofile is required')
return 1

for sofile in args:
if not check_symbol(sofile, options.allowlist):
return 1

return 0


if __name__ == '__main__':
sys.exit(main())

0 comments on commit 780e5fe

Please sign in to comment.